Stop mouse click event after click on button

Godot Version



I have a button on my 2D HUD overlay. When I click the button, the main scene’s input event handler is still catching that click. What do I have to change to make sure that the event handling stops with the button’s event handling and does not get passed through?

In the video you can see that a click on the 3D object opens its properties window and a click on the button spawns a new object. But if the cursor is over the button and behind the button there is the 3D object, it triggers the event handling of the scene and not the 2D overlay.

The button’s mouse_filter property is set to Stop

What callback you’re using in you main scene? Because if you’re using _input callback this will be called no matter you set on your mouse filter, mouse_filter only stops the propagation of _gui_input callback. Godot order of calling input callbacks is: _input, _gui_input and _unhandled_input

it is actually _input because I need to capture the clicks on the 3D objects. Or is there another way to do it?

Try use _unhandled_input

1 Like

nice, that worked - thanks! :slight_smile: