Skip to content

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
@Repiteo Repiteo merged commit f27f917 into godotengine:master Sep 19, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 19, 2025

Thanks!

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
4 participants