Godot Version
4.3.stable.mono
Question
get_global_mouse_position() causes _on_mouse_entered() and _on_mouse_exited() to misbehave
I need to check for mouse position in two places in two different ways (so far) and this causes an issue:
- A series of control nodes check for _on_mouse_entered() and _on_mouse_exited() (a series of Control nodes that perform a function on hover)
- Apart from that, in another (non-overlapping) part of the screen, I check if the mouse global position (get_global_mouse_position()) is within some bounds. (manually checking if the mouse is over an area, populated by a tilemap)
The two parts clash and I canât seem to make them coexist properly: The 2 part works, but the 1 part breaks: when I hover over any of the Control nodes for part 1, _on_mouse_entered() is executed and then _on_mouse_exited() is executed immediately afterwards, without the mouse really exiting.
I tried getting the mouse position for 2 in _process() and in _unhandled_input(), with the same effect.
If I remove the get_global_mouse_position() functionality for part 2, the part 1 hover works perfectly.
I also tried setting the mouse filter property of the control nodes to âPassâ.
I presume the problem is that my mouse position is being âstolenâ by the continuous checks of get_global_mouse_position(), but I have found no way to confirm or get around that. Ideally, I would like to be able to check the global mouse position regardless of any _on_mouse_entered / exited checks.
How is this done?
This is the main scene:
The supply node is a separate scene with the following structure:
Each âmarker_â in the Supply scene has the following structure:
This is the hover code for the markers (supply spots):
And this is the code in the script, attached to âMapâ in the main scene, that tries to do something with the mouse global position (currently the _process() attempts is commented out):