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

InputEventAction is_match method ignores exact_match parameter #63108

Closed
OverloadedOrama opened this issue Jul 17, 2022 · 0 comments · Fixed by #63109
Closed

InputEventAction is_match method ignores exact_match parameter #63108

OverloadedOrama opened this issue Jul 17, 2022 · 0 comments · Fixed by #63109

Comments

@OverloadedOrama
Copy link
Contributor

OverloadedOrama commented Jul 17, 2022

Godot version

3.4.4, 3.5-rc6 and 4.0.alpha (custom build)

System information

openSUSE Tumbleweed with KDE Plasma

Issue description

InputEventAction's is_match method completely ignores the exact_match parameter and it is always false. This bug also happens on 3.x's shortcut_match method.

As a result, button nodes with ShortCuts get fired even if the key combination is not exact. In the minimal reproduction project, there are two buttons, one with a ShortCut with an InputEventAction mapped to the S key, and another button mapped to Control + S. On Godot 3.x, both buttons get fired while holding Control + S, while only the second button should get fired. On Godot 4.x, Control + S only executes the second button, but S does not seem to release the first button. Both issues are seemingly solved if InputEventAction's is_match takes exact_match into account, which is true by default. I will soon open a PR that provides a fix.
EDIT: The PR is #63109.

If this behavior is intentional, then it might be worth it to introduce a new property for ShortCut, that lets users decide if the ShortCut should check for exact matches or not. Although, from my understanding, this is not intentional, since all other InputEvents in ShortCuts are exact matches, with no way to change that, so InputEventAction should be too.

Steps to reproduce

  1. Create two input actions in the Input Map, one with a single key button and another with the same button but with a modifier. For example, S and Control + S.
  2. Create two Button nodes and provide a ShortCut for each of them. For the first button's ShortCut, add an InputEventAction that corresponds to the single key button input action (in our example, S), and for the second button's ShortCut, add an InputEventAction that corresponds to the key button with a modifier input action (in our example, Control + S).
  3. Run the project. If you are in Godot 3.x, press Control + S and both buttons will get pressed. If you are in Godot 4.x, press S. The first button will get pressed but won't be released, and thus won't fire a pressed signal if the action mode is set to Button Release.

Minimal reproduction project

The project is for 4.0, but a similar project made for 3.x has the same issue.
InputEventAction bug.zip

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

Successfully merging a pull request may close this issue.

3 participants