Specify that holding Mouse Button down on a Control will prevent mouse_exited
on itself and mouse_entered
on others until release.
#4266
Labels
area:class reference
Issues and PRs about the class reference, which should be addressed on the Godot engine repository
enhancement
Milestone
Godot Engine v3.2.3.stable.official
Current Documentation:
Both found at :
https://docs.godotengine.org/en/stable/classes/class_control.html#signals
Issue Summary:
It is not documented and not intuitive that the Control class's
mouse_entered
signal will not fire if mouse button is clicked over another Control, then (without releasing the mouse button) the mouse is moved within the bounds of the Control node which has themouse_entered
signal connected.This happens because the
mouse_exited
signal is not triggered for the first Control (even if the mouse is outside the Control) until the mouse is released.This blocking happens any time the first Control is clicked and it has a
mouse_filter
of "Stop" or "Pass", regardless of whether the first Control has signals or a script with_gui_input(event)
.All other controls will have
mouse_entered
andmouse_exited
and mouse motion detected in_gui_input(event)
blocked until the mouse is released, even if the mouse is within their Rect area.Detailed Example for
mouse_entered
andmouse_exited
signals:Scene Tree Setup:
Pass
.mouse_entered
signal to print to console.mouse_exited
to print to console.)Expected Behavior, based on the Docs:
When no mouse button is held, Control derived nodes which connect their
mouse_entered
signal work as expected, any time the mouse initially enters the bounds of their Rect area.Clicking on a blank area of the screen, holding the mouse button down, then hovering over Controls will trigger each
mouse_entered
as expected. As does clicking and holding on a Sprite, then moving the mouse over the Control before releasing the mouse button.Unexpected Behavior, based on the Docs:
The following happens with Left Mouse Button, Right Mouse Button, or Middle Mouse Button.
A Control derived node will not fire
mouse_entered
ifmouse_entered
is not obstructedand has
mouse_filter
set to "Pass" (or "Stop").of the node connected to
mouse_entered
.Upon releasing the mouse, the
mouse_entered
signal immediately fires.If the first Control has
mouse_exited
it will also emit at this point.Demonstration:
Two Label nodes with
mouse_filter
set to "Pass".Each has
mouse_entered
connected to itself, and prints to output.For simplicity,
mouse_exited
is not connected in this demo.(Note:
The yellow circle represents when the mouse is held down.
It is not part of Godot -- it's an overlay feature of ScreenToGif.)
Suggestion:
I'm assuming this is expected (and at times desired) behavior.
But this behavior seems to be undocumented & contradicts the documentation
for the
mouse_entered
signal:Similarly,
mouse_exited
does not always emitI'd like to propose just a few details be added here to reflect this case.
Identical Behavior using
_gui_input(event)
instead of (or in addition to) signalsThis behavior (of clicking on one control, then all
mouse_entered
signals on all other control nodes being blocked until the mouse button is released) happens identically if some (or all) of the signals are replaced with_gui_input(event)
functions waiting for InputEventMouseMotion over the control node.The outcome is identical to the demo above.
This behavior using
_gui_input(event)
is unexpectedgiven this currently listed information :
https://docs.godotengine.org/en/stable/classes/class_control.html#class-control-method-gui-input
API -> class Control -> Methods -> void _gui_input ( InputEvent event ) virtual
The Control which is clicked does not need to have a
_gui_input(event)
in order for it to block theInputEventMouseMotion
in another Control node's_gui_input(event)
.Regarding "clicking outside the control":
If anything other than a Control is clicked and held, a node listening for mouse motion in
_gui_input(event)
will fire, even when the click originated outside its Rect area. So the current description for_gui_input(event)
is partially describingInputEventMouseButton
's bounds within_gui_input()
(which is very useful), but not the specific bounds of when_gui_input(event)
itself is triggered (or blocked by other gui elements).Suggestion:
I'd like to propose adding a little detail here to clarify that when holding the mouse button down on one Control, other Controls with
_gui_input(event)
functions will be blocked. (I haven't read the code for this, so I'm unsure if it's more complicated or nuanced than this, but even a little more information will save users from discovering this rule through trial and error alone).This took a while to figure out all the different bounds and interactions of this behavior, so I hope this is useful.
I absolutely love these docs,
(+) I appreciate everyone who puts effort into Godot.
Thanks for your time.
The text was updated successfully, but these errors were encountered: