-
Notifications
You must be signed in to change notification settings - Fork 155
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
Use consistent key bindings in FindReplaceOverlay on MacOS #2007 #2008
Conversation
@BeckerWdf Can you confirm that these changed key bindings make sense on MacOS? ExampleCurrentOpen find/replace overlay: CMD+F NewOpen find/replace overlay: CMD+F |
With your patch it's CMD-Shift-W. But the tooltip still says CTRL-W |
Test Results 1 210 files - 605 1 210 suites - 605 1h 0m 24s ⏱️ - 32m 2s For more details on these failures, see this check. Results for commit ca7b586. ± Comparison against base commit 337f4ba. This pull request skips 3 tests.
♻️ This comment has been updated with latest results. |
You are right, the tooltip has to be adapted as well, thanks! I think we should try to adapt the tooltip to use the proper modifier icon like in the menus. I will check that. But do you agree with me that, in general, CMD instead of CTRL should be used on MacOS for these shortcuts?
I don't think so, they are currently hard coded. |
Yes.
I think this should also be changed. |
@BeckerWdf I am not sure if that is sensible - the keybindings are not actions like the actions which are targetted by the settings of the "keys" page. Maybe the keybindings should be editable somewhere else? |
Maybe the keybindings should be editable somewhere else?
|
I understand! Then let's use the "keys" page.
I am not really sure - from my understanding yes, but my understanding is extremely limited! Maybe somebody can shed light on this? |
d2a5ac3
to
66e7f9d
Compare
We have extracted the custom binding of keys into a separate issue: #2015. I have adapted this PR so that tooltips show the OS-dependent shortcuts and also use modifier icons on MacOS to be consistent with the presentation of shortcuts at other places (in particular, menus). |
I have some improvement suggestion regarding the formatting of the keybindings. It's up to you if you want to consider this or not. |
Improvement suggestions are always appreciated 🙂 I will gladly adopt them. |
@@ -70,6 +74,8 @@ | |||
* @since 3.17 | |||
*/ | |||
public class FindReplaceOverlay extends Dialog { | |||
private static final String MOD1_KEY_STRING = OS.isMac() ? "⌘" : "Ctrl+"; //$NON-NLS-1$//$NON-NLS-2$ |
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.
There's a util that does that for you:
See: org.eclipse.jface.bindings.key.KeySequence#org.eclipse.jface.bindings.key
This is also used for formatting they shortcuts in the empty text editor's onboarding implementation.
See: ModeledPageLayout#addEditorOnboardingCommandId
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.
That looks great, thank you! I will try to adapt this PR using that functionality.
Ups.... |
b2c0218
to
2445c9f
Compare
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.
Works fine and looks good
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.
Very Sensible way of extracting keyboard shortcuts from the handler code and at the same time address the formatting of the shortcuts! Thanks 😀
searchUpButton = new AccessibleToolItemBuilder(searchTools).withStyleBits(SWT.PUSH) | ||
.withImage(FindReplaceOverlayImages.get(FindReplaceOverlayImages.KEY_FIND_PREV)) | ||
.withToolTipText(FindReplaceMessages.FindReplaceOverlay_upSearchButton_toolTip) | ||
.withSelectionListener(SelectionListener.widgetSelectedAdapter(e -> performSearch(false))).build(); | ||
.withToolTipText(MessageFormat.format(FindReplaceMessages.FindReplaceOverlay_upSearchButton_toolTip, |
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.
Nit: How about extracting the formatting of tooltips into a "addShortcutToToolTipText" method?
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.
Maybe even add a "withShortcutHint" method to the ToolItemBuilder, which takes a shortcut and adds it to the ToolTip?
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.
Good point! I have added a helper method in ca7b586.
Integrating the shortcut into the tool item (or its builder) would be even better. I am already working on a follow-up cleanup that better integrates shortcuts with operations, as well as the operations assigned to shortcuts and "usual" item clicks, which will cover that proposal in some way. Currently, there is quite some manual effort to initialize everything consistently. But that should not prevent us from having this improvement merged and is also easier to review in separation.
…atform#2007 Currently, the opening action for the find/replace overlay uses a key binding with the OS-dependent "modifier 1" (mapping to CTRL on Windows/Linux and CMD on MacOS), while all key bindings within the overlay (such as activating search options) use key bindings with CTRL as a modifier. In order to unify the key bindings, this change adapts the key bindings within the overlay to also use the OS-dependent "modifier 1", such that on MacOS the CMD modifier is used. The change also adapts the shortcuts to be represented as KeyStroke instances and uses them to match actual key combinations as well as to produce the string representation of the shortcuts for the tooltips. Fixes eclipse-platform#2007
Currently, the opening action for the find/replace overlay uses a key binding with the OS-dependent "modifier 1" (mapping to CTRL on Windows and CMD on MacOS), while all key bindings within the overlay (such as activating search options) use key bindings with CTRL as a modifier.
In order to unify the key bindings, this change adapts the key bindings within the overlay to also use the OS-dependent "modifier 1", such that on MacOS the CMD modifier is used. The change also adapts the tooltips to (1) reflect the changed keys and (2) represent the MacOS modifier keys via icons like at all other places.
Fixes #2007