#_unhandled_input behaves unexpected when pressing UI

2 messages · Page 1 of 1 (latest)

glass compass
#

Hello,
I am currently trying to make an simple UI for what boils down to just an sand box where i am latter gonna put in some algorithms.
The issue is i don't want the tile map below the ui (it's a 2D sandbox with tiles for walls and "cores" , i am using TileMapLayer for this ) to register an input when the cursor is on an UI element. I read that using func _unhandled_input() -> void: should solve the problem but here is the issue it for some reason get's registered by the button and the underlying tilemap. So is it both handled and unhandled ? Because if i put an debug message in to the _input function of the button script i get messages
I do the (admittedly) the button quit dump by trying to do the handling inside the button (i tried the easiest option considering that what i am building isn't supposed to be pretty)

the picture shows how a "core" was set behind the start button when pressed

I hope this made sense

digital echo
# glass compass Hello, I am currently trying to make an simple UI for what boils down to just an...

https://docs.godotengine.org/en/stable/tutorials/inputs/inputevent.html
tldr: input events have to be accepted so they don't propagate further. control nodes will by default accept when you "click" on them when their mouse mode is set to "stop". if you want to do that yourself set it to "pass" and use accept_event() inside _gui_input().
in general you can prevent an input event to propagate by calling get_viewport().set_input_as_handled() inside one of the other input-virtuals, like _input() , _unhandled_input() , etc.