Skip to content

Comments

Fix spacebar panning not working after focus leaves the map view#4338

Open
Oval17 wants to merge 1 commit intomapeditor:masterfrom
Oval17:fix/spacebar-panning-focus-detection-clean
Open

Fix spacebar panning not working after focus leaves the map view#4338
Oval17 wants to merge 1 commit intomapeditor:masterfrom
Oval17:fix/spacebar-panning-focus-detection-clean

Conversation

@Oval17
Copy link

@Oval17 Oval17 commented Feb 20, 2026

Resolves : #4295
Fixes: spacebar pan fails on first click after focus leaves the map view

SpaceBarEventFilter was installed on MainWindow, so it only saw Space key events that propagated up to the main window. Widgets like the Layers dock tree view consume Space themselves (to expand/collapse nodes), so the filter never saw the press and mSpacePressed stayed false. The next click in the map then activated the current tool instead of panning.

Fix: install the filter on qApp so it receives all key events in the application regardless of focus. Added a guard to skip events sent to text-input widgets (WA_InputMethodEnabled) so typing spaces in QLineEdit/QPlainTextEdit fields doesn't accidentally enable pan mode.

Kindly review and have a look @bjorn
Thanks

SpaceBarEventFilter was installed on MainWindow, so it only received
Space key events that propagated up to the main window. When another
widget (e.g. the Layers dock tree view) had keyboard focus and consumed
the Space key press, the filter never saw it, leaving mSpacePressed
false. The first click in the map viewport would therefore activate the
current tool instead of panning.

Fix by installing the filter on qApp instead, which receives all key
events dispatched in the application regardless of which widget holds
focus. A guard is added to skip Space events sent to widgets with
WA_InputMethodEnabled (QLineEdit, QPlainTextEdit, etc.) so that typing
spaces in text fields does not accidentally enable pan mode.
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.

Spacebar doesn't work on first drag after clicking on other elements

1 participant