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

Shortcut object not properly matching Pressed state #75318

Open
Haledire opened this issue Mar 25, 2023 · 1 comment
Open

Shortcut object not properly matching Pressed state #75318

Haledire opened this issue Mar 25, 2023 · 1 comment

Comments

@Haledire
Copy link

Godot version

4.0.1 stable

System information

Windows 10

Issue description

When making a shortcut for a Button - the Pressed component of the event seems to be ignored. Meaning - a Button that should only be reacting to Release type events (an InputEventKey with presssed = false) will only fire on pressed = true, which doesn't properly match the kind of InputEventKey action it should.

What's worse - if you actually press the button, now it fires on Press AND Release of the shortcut. This doesn't feel like the expected behavior from the options available when building a Shortcut

Steps to reproduce

Create an empty project and make a Scene with only a Button
Add the below script to the button:

extends Button

func _ready():
  pressed.connect(func():print("Fired Pressed"))

Add a Shortcut resource to the Button. Give it an InputEventAction and set the action to ui_accept. Leave pressed unchecked.
image

Make the Button big enough that you can click it in the running scene.
Run the scene and press the Enter key - you will notice that the event fires when the Enter key has been pressed, not when it is released

Use the Mouse to click the Button. At base settings, the press signal will fire on the release of the mouse button.

Now press the Enter key again - notice that now the pressed signal is firing not only on press, but also on release

Minimal reproduction project

ShortcutBug.zip

@KoBeWi
Copy link
Member

KoBeWi commented Jun 27, 2023

This is not really a bug, button shortcuts are designed to fire only on press, see #71328
We could make Button respect action mode or shortcut's pressed flag, but the problem is that both default to "release", which would break editor shortcuts for the aforementioned reasons.

For now we can document it as intended behavior. Release shortcuts could be implemented as a separate flag, but it needs a proposal.

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

No branches or pull requests

3 participants