Is there a way to tell if a mouse exits a button's collision while holding down left click?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By catiosis

I know about .is_hovered() and the ability to refer to “mouse_exited” as a function, but if you hold down left click while exiting the box it will not change until you release the button. Are there any ways I can tell if the collision of a button has been left while left click is held? Ideally without adding extra children to the button but if that is the only way then I can accept it.

:bust_in_silhouette: Reply From: Wakatta

Compare the mouse position to the rect of that button

extends Button

func is_over():
    return get_rect().has_point(get_local_mouse_position())

Ideally called in the _input() function anytime the mouse is moved