-
-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show partial shortcut while editing. #6050
Conversation
In this video:
Untitled.mov |
@jni I think you were asking for this also, and were excited about shortcuts editor showing modifiers. |
Codecov Report
@@ Coverage Diff @@
## main #6050 +/- ##
==========================================
+ Coverage 91.62% 91.64% +0.02%
==========================================
Files 579 580 +1
Lines 50663 50858 +195
==========================================
+ Hits 46419 46609 +190
- Misses 4244 4249 +5
|
Note that with napari/docs#200 we should be able to drop modifiers only shortcuts. |
This looks great, but in your example assigning |
I completely agree, but this pull request is not to discuss whether modifiers only keybindings are good to have. I agree they are not and nap7 also says so. It's here just to fix the bug that modifier. In the default shortcuts there is at least one "Reset Scroll" that is just a modifier (Ctrl), so my goal is just to let people enter shortcuts that are already assigned, and thus contain only modifiers. |
I understand. But being able to assign |
Was there any actual decisions ? I'm happy to remove the code that allows to bind only modifiers. |
Very wierd, I still can't get |
I remove the explicit handling and messaging around Return and Modifiers only. |
So I'm confused by the current implementation. While the info text at the bottom no longer mentions confirming via return, double modifiers like alt-meta on macOS can still be bound (but don't actually work) using return. |
And automatically accept/validate shortcuts when valid. - When receiving a modifier only event, use the event Modifiers to show the current partial shortcuts. - we need to handle keyrelease events otherwise the following sequence is incorrect. ``` Action – Shortcut shown --------------------------------- Press Ctrl – Ctrl Also Press Alt – Ctrl-Alt Release Ctrl – Ctrl-Alt ``` Though now that we handle release, the user cant press a shortcut and then validate with enter as as soon as the user release the shortcut the QLineEdit will become empty. Thus validate as soon a shortcut is valid, and contain a non-modifier key. This in turn make it impossible to assign a modifiers only keybinding, I assume this is quite rare, but we can use on of the keys that are invalid as shortcut to validate modifiers only shortcuts. I choose Qt.Return, aka `Enter`. I'm not quite confident on the Return/Enter, and the way to assign modifiers only shortcuts. There is also this whole Meta/Alt/Ctrl are not the same on MacOS. I did not extract the logic into naprai/utils/interactions as those are Qt Specific, moreover the values of QtEvent.Modifiers are not the same than Qt.Keys. You will note that there is one weirdness in the order of modifiers when typing these, but I believe this will be fixed upstream. Closes napari#6047
@@ -352,7 +354,7 @@ def _show_bind_shortcut_error( | |||
|
|||
message = trans._( | |||
"<b>{new_shortcut}</b> is not a valid keybinding.", | |||
new_shortcut=new_shortcut, | |||
new_shortcut=Shortcut(new_shortcut).platform, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show platform specific error messages.
rebased on master also as there was some weird things going on with Ctrl/Cmd on mac that would sometime display improperly. After rebase this seem fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good now, thanks @Carreau
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work, LGTM!
Co-authored-by: Kira Evans <contact@kne42.me>
thanks !
|
And automatically accept/validate shortcuts when valid.
When receiving a modifier only event, use the event Modifiers to show the current partial shortcuts.
we need to handle keyrelease events otherwise the following sequence is incorrect.
Though now that we handle release, the user cant press a shortcut and then validate with enter as as soon as the user release the shortcut the QLineEdit will become empty. But we don't care as we only want full shortcuts and not modifiers only.
Thus validate as soon a shortcut is valid, and contain a non-modifier key.
There is also this whole Meta/Alt/Ctrl are not the same on MacOS. I did not extract the logic into naprai/utils/interactions as those are Qt Specific, moreover the values of QtEvent.Modifiers are not the same than Qt.Keys.
You will note that there is one weirdness in the order of modifiers when typing these, but I believe this will be fixed upstream. This is due to the fact that when pressing
Ctrl
thenShift
for example,Shift
is theKey
event, and this will appear at the end. While when doingShift
, thenCtrl
, ctrl is the key that will appear at the end.Closes #6047
Type of change
How has this been tested?
This needs to be tested on more platforms.