Switch to the Select tool when Escape is pressed in a view#1023
Open
roor0 wants to merge 1 commit into
Open
Conversation
Pressing Escape in a model view now returns to the default Select tool, providing a quick way to exit the Insert, Eraser, or other active tools from the keyboard.
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.
What
Pressing Esc while a model view has focus now switches back to the default Select tool. This gives a quick keyboard way to exit the Insert, Eraser, or other active tools without reaching for the toolbar.
Why
Esc to return to the default/neutral state is a near-universal convention in editing tools, and there is currently no keyboard way to leave a tool such as Insert or Eraser once it is active.
Why not just an assignable shortcut?
I first tried doing this purely through the existing Preferences keyboard-shortcut system (binding Esc to
Edit.Tool.Select), since the project generally prefers user-assignable shortcuts. That did not work: when the OpenGL view (lcViewWidget) has focus it receives the key event first, so theQActionshortcut (defaultWindowShortcutcontext) never fires for keys pressed over the 3D view.Handling Esc directly in
lcViewWidget::keyPressEventis the reliable fix, and a fixed Escape binding is consistent with the universal "escape returns to the default state" convention.Implementation
Qt::Key_EscapeinlcViewWidget::keyPressEventand callsgMainWindow->SetTool(lcTool::Select).lcViewType::View) so it does not affect preview widgets.gMainWindow, accepts the event, and falls through to the default handler for every other key, leaving existing Ctrl/Shift handling untouched.