-
Notifications
You must be signed in to change notification settings - Fork 13
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
Question: how to specify KeyMod of Control for all platforms? #229
Comments
can you clarify where exactly you're specifying these? You might be looking a bit low in the codebase... My expectation was that, most of the time, keybindings would be declared as keybinding rules (either during the declaration of a plugin or in an Action for an application). is that what you're trying to do here? or are you doing something special at a lower level |
a general answer to your question is that KeybindingRules allow for platform specific logic. So, if just saying since this all follows the vscode specification for declaring keybindings, you might find it useful to see how a vscode app/extensions declares stuff. Here's an example with a ton of keybindings declared: I can also write up a short example of how you could test stuff out locally a little more directly if that would be helpful |
Well, specifically here:
That resolves to Control-Del everywhere, but Command-Del on macOS which is a system keybind and as a result don't work. The idea was to make it Control-Del everywhere, so I naively tried |
I see, that list has lost the ability to declare platform specificity. Well, how about you try WinCtrl (regardless of what my comment said), and if it doesn't do what you need, you might need to extend the concept of your default key bindings to allow for platform specificity |
I think it's best to make that a 2nd key binding. Thanks for the insight -- I will close as an explicit KeyMod.Ctrl isn't going to be a thing. |
I'm not 100% sure about this yet :) reopening. been looking some more, I haven't found a good explanation yet of why not to have |
Eeep! Sorry! |
one additional thing I noted: if you use the string form: |
Maybe i'm dense, but: using " " instead of [ ] gives Full traceback for the record
|
indeed. it would need to be a string :) |
let's back up a bit... keys can be encoded as strings you definitely can't combine the two, so you can't do when it comes time to actually convert those to an OS-bound keybinding, it will pass through app-model/src/app_model/types/_keys/_keybindings.py Lines 295 to 305 in a0d95b1
and there, it will receive slightly different behavior depending on if it's in a string or integer form: app-model/src/app_model/types/_keys/_keybindings.py Lines 71 to 93 in a0d95b1
note that the so, without looking deeper at how napari actually processes those lists you have there, I would expect you should be able to use:
|
I would actually dig into this a bit more... i would 100% expect to be able to delete a layer with cmd+del on macos... and |
There is no error, I assume it's processed by the OS. |
i guess I mean, what do you mean when you say "as a result don't work" ... what is the behavior? does nothing at all? |
Yeah, nothing. If I bind Shift-Del or whatever it works. But Command-Del doesn't -- I assume because it's a system binding. |
yeah: what I'm saying is that ... if it's just an assumption, before you commit to an unusual non-standard keybinding... seems like it would be worth answering that question convincingly. it would actually surprise me if, in Qt, you can't bind cmd-del to anything you want. It may be that you need to override some default Qt behavior, but i would be surprised if it's actually a lower level OS limitation (plenty of applications use cmd-del to delete stuff) |
I almost wonder if it's related to backspace vs delete? |
it would be super helpful to reduce the problem to a mwe... rather than going through the entire napari app. if you can do that and demonstrate no Qt response, i'd be happy to look into it |
Boom. If i change it to : |
:) |
Yup! if I go back to the original and use |
you can: with strings... as I look into this, one reason I think they probably avoided having both the more useful |
Makes sense. |
I'm not quite sure exactly what napari does with that list: |
So how would you encode that without |
yep |
KeyMod.CtrlCmd results in Ctrl on windows (and linux?) but Cmd on macOS
KeyMod.WinCtrl says it does Meta on Windows and Ctrl on macOS
Is there a way to specify a Control-Foo binding that uses Control on all platforms?
KeyMod.Ctrl does't exist, but there is KeyCode.Ctrl
Based on
app-model/src/app_model/backends/qt/_qkeymap.py
Lines 220 to 238 in a0d95b1
it looks like it wouldn't be easy to have two different KeyMod map to the same QCTRL...
The text was updated successfully, but these errors were encountered: