Skip to content

Defer click selection when starting area-select rectangle drag#3542

Open
nklbdev wants to merge 1 commit into
JannisX11:nextfrom
nklbdev:preview_clicks_as_complex_events
Open

Defer click selection when starting area-select rectangle drag#3542
nklbdev wants to merge 1 commit into
JannisX11:nextfrom
nklbdev:preview_clicks_as_complex_events

Conversation

@nklbdev

@nklbdev nklbdev commented May 2, 2026

Copy link
Copy Markdown
Contributor

Problem: When starting an area-select rectangle drag from the surface of a mesh element, mousedown immediately triggers a click that selects the element — before the drag even begins. This is especially disruptive when using Shift to extend selection: the unwanted element gets selected on mouse-down, and the rectangle then operates on a polluted selection state.

Fix: When the preview_area_select keybind triggers, normal click processing is skipped entirely. Control goes directly to startSelRect(). If the mouse is released without significant movement, the saved event is replayed as a deferred click via stopSelRect() — so single clicks still work as expected. A replaying_click flag on this.selection prevents the guard from intercepting the replay and blocks startSelRect from being called again from within the replayed click handler.

Flow:

Event Behavior
mousedown (area-select) Skip click, save deferred_event, call startSelRect
mousemove with rectangle activation Selection via viewportRectangleOverlap
mouseup (was drag) Undo.finishSelection('Area select')
mouseup (no drag) replaying_click = trueclick(deferred_event) → normal click processing

@nklbdev nklbdev changed the base branch from master to next May 2, 2026 15:14
@nklbdev nklbdev force-pushed the preview_clicks_as_complex_events branch from 27d145d to b4c667a Compare May 18, 2026 08:47
@netlify

netlify Bot commented May 18, 2026

Copy link
Copy Markdown

Deploy Preview for blockbench-dev ready!

Name Link
🔨 Latest commit d7ea93b
🔍 Latest deploy log https://app.netlify.com/projects/blockbench-dev/deploys/6a10da8c54fd310008b15239
😎 Deploy Preview https://deploy-preview-3542--blockbench-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@nklbdev nklbdev force-pushed the preview_clicks_as_complex_events branch 2 times, most recently from 50533a7 to 23b01fc Compare May 18, 2026 20:24
@nklbdev nklbdev force-pushed the preview_clicks_as_complex_events branch from 23b01fc to d7ea93b Compare May 22, 2026 22:36

@JannisX11 JannisX11 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take another look at the issue you described. But depending on keymap, the binding to click-select and the binding to area-select are both left mouse button, and this change moves the actual selection effectively to the mouseup event, which is not intended.

@nklbdev

nklbdev commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Yes, that's right. Event handling is delayed until the release. I still need to add my final local edit to this code: disabling this behavior for drawing tools. Otherwise, the behavior in this mode is extremely good and pleasant, and quite expected.

It's quite possible that if you want to include this behavior in your release, you'll have to implement it slightly differently (you know best how to do it correctly). But overall, from UX perspective, this is very good. You can safely click a button and drag to select multiple faces of the current mesh without worrying that the click will be fully activated and select a face of a CLOSER, but not selected mesh.

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.

2 participants