0 votes

I know about .ishovered() and the ability to refer to "mouseexited" 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.

Godot version 3.5.1
in Engine by (12 points)

1 Answer

+1 vote

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

by (6,876 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.