0 votes

I want a button that have interaction like this

Button down > Button up > Do something
Button down > Move outside button area > Button up > Doesn't do anything

so i create a code

extends TextureButton

var hovering = false
var exited = false

func _ready():
    self.connect("button_down", self, "Button_Down")
    self.connect("button_up", self, "Button_Up")
    self.connect("mouse_entered", self, "Mouse_Entered")
    self.connect("mouse_exited", self, "Mouse_Exited")
func Mouse_Entered():
    print("mouse enter")

func Mouse_Exited():
    hovering = false
    exited = true
    print("mouse exit")

func Button_Down():
    exited = false

func Button_Up():
    if not exited:
        #do something

func Interact():

when I
Button down > Move out > Button up
the result is:


Interact() still trigger
seem like mouse_exited doesn't trigger when mouse button down

is there anyway to fix this ?

in Engine by (14 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.