Freeze the scrollbar while editor is open in property browser.

Before this commit, the scrollbar would move freely, without changing
the position of the viewport. It would be reset after editing is
finished.
pull/507/head
whitequark 2019-11-23 15:06:36 +00:00
parent f0359556d8
commit 8c750cef9c
3 changed files with 11 additions and 4 deletions

View File

@ -952,9 +952,10 @@ public:
}
void SetScrollbarPosition(double pos) override {
if(pos > ssView.scrollerMax) {
if(pos > ssView.scrollerMax)
pos = ssView.scrollerMax;
}
if(GetScrollbarPosition() == pos)
return;
[nsScroller setDoubleValue:(pos / (ssView.scrollerMax - ssView.scrollerMin))];
if(onScrollbarAdjusted) {
onScrollbarAdjusted(pos);

View File

@ -1354,7 +1354,11 @@ public:
SCROLLINFO si = {};
si.cbSize = sizeof(si);
si.fMask = SIF_POS;
si.nPos = (UINT)(pos * SCROLLBAR_UNIT);
sscheck(GetScrollInfo(hWindow, SB_VERT, &si));
if(si.nPos == (int)(pos * SCROLLBAR_UNIT))
return;
si.nPos = (int)(pos * SCROLLBAR_UNIT);
sscheck(SetScrollInfo(hWindow, SB_VERT, &si, /*redraw=*/TRUE));
// Windows won't synthesize a WM_VSCROLL for us here.

View File

@ -1129,8 +1129,10 @@ void TextWindow::MouseLeave() {
}
void TextWindow::ScrollbarEvent(double newPos) {
if(window->IsEditorVisible())
if(window->IsEditorVisible()) {
window->SetScrollbarPosition(scrollPos);
return;
}
int bottom = top[rows-1] + 2;
newPos = min((int)newPos, bottom - halfRows);