|Topic was automatically imported from the old Question2Answer platform.
I´m having difficult understanding what I suppose should be a simple task.
I have a clickable map so that when i click over objects on the map I can select them, but of course I dont want the player to be able to click on the map THROUGH the GUI.
So I declared a
mouse_on_map boolean variable to hold information about the position of the mouse, and linked it to GUI panels with
However it seems like that every button inside the monitored areas automatically trigger the
mouse_exited() signal, setting
mouse_on_map=true and tricking the game to think that the mouse is on the map and allowing the pressing of the button and selecting the map at the same time.
I know this thing should be managed with the mouse filters, but any combination of stop/pass/ignore seems not to work.
Can you explain the right combination of mouse filter of the parents and children nodes?
PS: is there a better way to mask the map and prevent it from being pressed rather than monitoring the mouse position? Something that block the mouse click to the first element it encounter?
How are you detecting clicks on the map?
Usually, things that aren’t GUI items should use
_unhandled_input, which will be called only when input isn’t handled by GUI nodes. It’s explained here: InputEvent — Godot Engine (3.0) documentation in English
If the UI doesn’t cover all the screen (which would allow mouse to go through a pause menu for example), you can have an invisible Control on the menu that takes the whole screen and then blocks the mouse. Then you won’t need any special boolean to monitor everywhere
Zylann | 2018-04-13 12:50
Wow, the _unhandled_input(event) is exactly what I was looking for!
So basically the code for selecting the map will fire only if the mouse click is not consumed by any other node or _input(event), correct?
Super useful to know, thank you!
Andrea | 2018-04-13 14:26