Skip to content
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

Binding commands to the same key #119

Closed
EverCursed opened this issue Dec 25, 2019 · 3 comments
Closed

Binding commands to the same key #119

EverCursed opened this issue Dec 25, 2019 · 3 comments

Comments

@EverCursed
Copy link

EverCursed commented Dec 25, 2019

A command binding may fail to register if the bindings are not in a specific order. From what I tried, a binding will fail to register if you register a key with more modifiers before a key with less modifiers (ctrl+shift+a before ctrl+a).

Bind(write_hack,         KeyCode_Y, KeyCode_Alt, KeyCode_Control); // was not registered
Bind(write_note,         KeyCode_Y, KeyCode_Alt); // this one was
@4coder-editor
Copy link
Owner

4coder-editor commented Jan 12, 2020

I agree this is weird, but it's technically how I "meant" for it to work, but it has proven sufficiently confusing for everyone that I am now investigating alternate binding resolution rules to make up for the confusion.

The primary problem is that I wanted to not have a "strict matching" rule. For instance, I wanted it to be the case that the key set the user binds can be [A B] and that can be triggered by any of:
[A B]
[A B C]
[A B D]
[A B C D]
etc.

The only limit is that the key the user hits HAS to be the particular one they bound. However this might not be worth it, perhaps I should just go for strict matching, or for some kind of "best matching" heuristic and only rely on order of declaration when there is no perfect match and a tie for best match. I'll have to start asking around to figure out what's best for everyone.

@EverCursed
Copy link
Author

EverCursed commented Jan 12, 2020

Honestly, I'm not sure that this kind of "fallback matching" rule is actually useful. Or to put it another way, I can't come up with a use case where you would rely on this rule. It seems to me that it is only useful when trying to find shortcuts for the first time, as it slightly increases the likelihood that the user will blindly hit a registered shortcut.

I'm not sure that this functionality is worth the a) increased complexity of the matching rule processing, and b) some limits on how the bindings need to be set up.

And also let's be honest, there will be someone who will bind ctrl+\ to delete_system32() and attempt (and fail) to bind ctrl+shift+\ to "make all identifiers uppercase".

I have not looked at how the keys are bound, but can you not just delay binding when calling Bind() and then before actually registering them, sort them by how many modifiers that binding has, or whatever determines the success of binding in this situation? This may allow you to just go around the issue for now.

@4coder-editor
Copy link
Owner

4coder-editor commented May 1, 2020

The reasons behind it are complex, but the short story is, you'd be surprised how bad it feels when certain things don't happen when you're unknowingly still holding a modifier.

However this issue should be largely fixed in 4.1.5 as there is now a more thorough matching rule that will always prefer exact matches anywhere in the command map over loose matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants