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

Unexpected behavior of button_up signal when focus is changed while ui_accept is pressed #52578

Closed
David1Socha opened this issue Sep 11, 2021 · 2 comments · Fixed by #81532
Closed

Comments

@David1Socha
Copy link
Contributor

Godot version

3.3.3

System information

Windows 10

Issue description

I'm seeing unexpected behavior with the button_up signal when focus is switched between buttons while holding a ui_accept button (and then releasing ui_accept after focus has changed). If I start holding ui_accept, a button_down signal is fired for the button under focus. This is as expected. However, if I use the arrow keys to navigate to a different button, and afterwards release the ui_accept button, no button_up signal ever gets fired for the button I initially selected, and a button_up signal is instead fired for the button that I've navigated focus to.

This behavior is unexpected to me for a few reasons:

  1. If I instead press a button with the mouse, then change focus, then release the mouse, I do not get the same signal behavior. Instead, button_down and button_up both fire for the original button I selected (even if I've moved the mouse around on the screen to a new location). This is the more expected result in my opinion.
  2. This behavior does not seem to correspond with the behavior of the pressed or toggled signals, which do not fire when I start pressing one button but navigate to another button before releasing ui_accept.
  3. Conceptually, I don't think it makes sense that it is possible for the button_up signal to fire for a button which has never been pressed down.

Instead of the current behavior, I would expect the following signal behavior when the steps described above are executed:

button_up signals always fire on the same button from which the initial button_down signal was triggered, firing once the ui_accept button has been released. In my opinion, this would be the most desirable behavior, to ensure consistency of button_up signal behavior between input types (matches current behavior when button is selected with a mouse and focus is changed).

Steps to reproduce

Attached a project with minimal reproduction steps (featuring two buttons, which log to the console whenever they receive button_up or button_down signals). In that project, if you focus the "Middle Button", hold a ui_accept button like spacebar, then navigate down to the "Bottom Button" while holding the ui_accept button, and release the accept button afterwards, the following events will fire.

Middle Button button_down has been triggered

Bottom Button button_up has been triggered

In my opinion, the expected output for this set of actions would instead be

Middle Button button_down has been triggered

Middle Button button_up has been triggered

Minimal reproduction project

repro.zip

@e8newallm
Copy link
Contributor

This seems to be a deeper problem that it initially appears.

With clicking buttons with the mouse, you maintain a link to the clicked button seemingly separate from the focus. The problem appears because the focus changing seems to make the event happen on the new focused button. This will be tricky because seemingly you can press different button using enter AND space (You can even seem to press the same button twice with both before a release has happened which concerns me)

Going to pick this up and see if there's any reasonable solution to this.

@Novark
Copy link

Novark commented Sep 7, 2023

May be tangentially related to, or even a symptom of #81186.

@akien-mga akien-mga added this to the 4.2 milestone Oct 23, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 30, 2023
@KoBeWi KoBeWi removed this from the 4.3 milestone Aug 1, 2024
@akien-mga akien-mga added this to the 4.4 milestone Jan 6, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in 4.x Priority Issues Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment