Skip to content

Keep mouse-wheel scroll position when clicking a tree node#1159

Open
bowenr-deshaw wants to merge 1 commit into
rivo:masterfrom
bowenr-deshaw:fix-treeview-mouse-scroll-snapback
Open

Keep mouse-wheel scroll position when clicking a tree node#1159
bowenr-deshaw wants to merge 1 commit into
rivo:masterfrom
bowenr-deshaw:fix-treeview-mouse-scroll-snapback

Conversation

@bowenr-deshaw

Copy link
Copy Markdown

Fixes #1044

After scrolling a TreeView with the mouse wheel and then clicking a
visible node, the wrong node ends up selected. The mouse button-press
triggers a redraw, and process() scrolls the selected node back into
view before the click is resolved, which shifts the rows out from under
the cursor so the following click lands on a different node.

This tracks when the user has scrolled with the mouse wheel and skips the
scroll-into-view step in process() while that is the case. The flag is
reset as soon as the selection actually changes, so keyboard navigation,
resizes, and changes to the tree still move the selection into view as
before.

To reproduce, build a tree taller than its viewport, scroll with the
mouse wheel until the selected node is off-screen, and click a visible
node. Before this change a different node is selected.

Listbox doesn't have this issue anymore so no changes are needed there.

Scrolling the TreeView with the mouse wheel and then clicking a node
caused the view to snap the selection back into view on the redraw
triggered by the button-press, so the following click selected the
wrong node. Track user scrolls and skip the scroll-into-view step
until the selection actually changes (resizes and tree changes still
scroll into view, as they do not set userScrolled).

Fixes rivo#1044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

listbox and tree will select wrong node after mouse scroll end

1 participant