Fix spacebar panning not working after focus leaves the map view#4338
Open
Oval17 wants to merge 1 commit intomapeditor:masterfrom
Open
Fix spacebar panning not working after focus leaves the map view#4338Oval17 wants to merge 1 commit intomapeditor:masterfrom
Oval17 wants to merge 1 commit intomapeditor:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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