• Godot HelpGUI
  • Detect if mouse is dragged off Button before release ?

This is for a 3d game where I want to use TextureButtons (or other Control elements) to detect mouse events. Mouse enter and exit work as expected, but I can't get the mouse click to work right. If I move the mouse over the btn and click -> this is fine : it detects the click If I move the mouse over the btn while the left mouse button is down (drag) -> no click detected (I can live with this :) ) If I move the mouse out of the btn while the left mouse button is down (drag) -> the click is still detected (but should have been cancelled = problem)

I've tried TextureButtons and ColorRectangles ; both have the same problem. I've tried using various combinations of the Control signals with _input(event) ; nothing seems to work. So it seems that mouse drag interferes with Control click events ... Suggestions very much welcome !

This is Windows 10 + Godot 3.1.1 or Godot 3.2beta4.

There should be mouse entered and mouse exited signals you could try using. The trick is to set up a boolean state you set to true or false based on mouse entered/exited, then in your button logic check for the state condition.

Yeah ... should work, but doesn't. :) Mouse enter/exit doesn't work when the mouse button is kept pressed down ...

I just checked Area2d, and that works as it should. But ... using 2d nodes in a GUI overlay in a 3d game ... ??? Is that safe ?

Should be fine, the 2D control nodes are meant for UI. Sounds like you may have found a bug. Consider reporting it as a new issue to the tracker if you can find a preexisting report already.

I'll take a look at the issues list ... Thanks for the help !

And so as to not get others confused : 'Area2d' is not a 'Control' node, but a 'Node2d' node. It should really only be used in 2d projects ... B)

EDIT : issue submitted (#34484)

3 years later