Skip to content

Fix mouse_entered and mouse_exited Signals being emitted too early #107955

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lodetrick
Copy link
Contributor

@lodetrick lodetrick commented Jun 24, 2025

Fixes #106953

Currently, the mouse_entered and mouse_exited signals are emitted in the notification method of Control. Since notifications are propagated downward from Control to inherited classes and downwards, this means that the signal will be emitted before any inherited classes have the chance to update their state based on the notification.

For example, in the Button class, is_hovered will not update before the signal is emitted and therefore any code that checks the state will have out of date values. This PR delays the signal emission until after the notification() call is fully propagated in order to give time for the internal classes to update their state.

I suppose if another solution isn't found that there should be discussion on how often users would call notification(NOTIFICATION_MOUSE_ENTERED) and expect a signal to be emitted. Ideally this would be called after the other classes, it would work with a deferred call but that should be discussed for latency.

@lodetrick lodetrick requested review from a team as code owners June 24, 2025 21:08
@akien-mga akien-mga added this to the 4.x milestone Jun 24, 2025
@AThousandShips AThousandShips changed the title Fix MouseEntered and MouseExited Signals being emitted too early Fix mouse_entered and mouse_exited Signals being emitted too early Jun 24, 2025
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine.

Control changes are prone to regressions though (even if they are "perfectly safe"), so it will have to wait for 4.6.

@KoBeWi KoBeWi modified the milestones: 4.x, 4.6 Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

is_hovered() returns inverted state for Button in Godot 4.4.1
3 participants