diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2023-01-06 21:48:20 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2023-08-01 13:28:49 +0200 |
commit | 1c3c17c608df7f05ba27a95f4a5ceb5e67f935d7 (patch) | |
tree | f0b8ba5b310cdddcf81e1e09613737517cea81db /doc | |
parent | da81ca62a5f6d615516929896caa0b6b09ceccfc (diff) | |
download | redot-engine-1c3c17c608df7f05ba27a95f4a5ceb5e67f935d7.tar.gz |
Refactor mouse_entered and mouse_exited notifications
The previous implementation for signals mouse_entered and mouse_exited
had shortcomings that relate to focused windows and pressed mouse buttons.
For example a Control can be hovered by mouse, even if it is occluded by
an embedded window.
This patch changes the behavior, so that Control and Viewport send
their mouse-enter/exit-notifications based solely on mouse position,
visible area, and input restrictions and not on which window has
focus or which mouse buttons are pressed. This implicitly also
changes when the mouse_entered and mouse_exited signals are sent.
This functionality can not be implemented as a part of
Viewport::_gui_input_event, because of its interplay with Windows and
because Viewport::_gui_input_event is based on input and not on
visibility.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/Control.xml | 16 | ||||
-rw-r--r-- | doc/classes/Node.xml | 4 | ||||
-rw-r--r-- | doc/classes/Window.xml | 4 |
3 files changed, 13 insertions, 11 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 54c38f2db9..ee790b6968 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1094,15 +1094,15 @@ </signal> <signal name="mouse_entered"> <description> - Emitted when the mouse enters the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. - [b]Note:[/b] [signal mouse_entered] will not be emitted if the mouse enters a child [Control] node before entering the parent's [code]Rect[/code] area, at least until the mouse is moved to reach the parent's [code]Rect[/code] area. + Emitted when the mouse cursor enters the control's visible area, that is not occluded behind other Controls or Windows, provided its [member mouse_filter] lets the event reach it and regardless if it's currently focused or not. + [b]Note:[/b] [member CanvasItem.z_index] doesn't affect, which Control receives the signal. </description> </signal> <signal name="mouse_exited"> <description> - Emitted when the mouse leaves the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. - [b]Note:[/b] [signal mouse_exited] will be emitted if the mouse enters a child [Control] node, even if the mouse cursor is still inside the parent's [code]Rect[/code] area. - If you want to check whether the mouse truly left the area, ignoring any top nodes, you can use code like this: + Emitted when the mouse cursor leaves the control's visible area, that is not occluded behind other Controls or Windows, provided its [member mouse_filter] lets the event reach it and regardless if it's currently focused or not. + [b]Note:[/b] [member CanvasItem.z_index] doesn't affect, which Control receives the signal. + [b]Note:[/b] If you want to check whether the mouse truly left the area, ignoring any top nodes, you can use code like this: [codeblock] func _on_mouse_exited(): if not Rect2(Vector2(), size).has_point(get_local_mouse_position()): @@ -1140,10 +1140,12 @@ Sent when the node changes size. Use [member size] to get the new size. </constant> <constant name="NOTIFICATION_MOUSE_ENTER" value="41"> - Sent when the mouse pointer enters the node. + Sent when the mouse cursor enters the control's visible area, that is not occluded behind other Controls or Windows, provided its [member mouse_filter] lets the event reach it and regardless if it's currently focused or not. + [b]Note:[/b] [member CanvasItem.z_index] doesn't affect, which Control receives the notification. </constant> <constant name="NOTIFICATION_MOUSE_EXIT" value="42"> - Sent when the mouse pointer exits the node. + Sent when the mouse cursor leaves the control's visible area, that is not occluded behind other Controls or Windows, provided its [member mouse_filter] lets the event reach it and regardless if it's currently focused or not. + [b]Note:[/b] [member CanvasItem.z_index] doesn't affect, which Control receives the notification. </constant> <constant name="NOTIFICATION_FOCUS_ENTER" value="43"> Sent when the node grabs focus. diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index ce02c3e51a..49ab3918bb 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -1052,10 +1052,10 @@ Notification received from the OS when the screen's DPI has been changed. Only implemented on macOS. </constant> <constant name="NOTIFICATION_VP_MOUSE_ENTER" value="1010"> - Notification received when the mouse enters the viewport. + Notification received when the mouse cursor enters the [Viewport]'s visible area, that is not occluded behind other [Control]s or [Window]s, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not. </constant> <constant name="NOTIFICATION_VP_MOUSE_EXIT" value="1011"> - Notification received when the mouse leaves the viewport. + Notification received when the mouse cursor leaves the [Viewport]'s visible area, that is not occluded behind other [Control]s or [Window]s, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not. </constant> <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="2009"> Notification received from the OS when the application is exceeding its allocated memory. diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 4114a83584..33a64be50c 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -719,12 +719,12 @@ </signal> <signal name="mouse_entered"> <description> - Emitted when the mouse cursor enters the [Window]'s area, regardless if it's currently focused or not. + Emitted when the mouse cursor enters the [Window]'s visible area, that is not occluded behind other [Control]s or windows, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not. </description> </signal> <signal name="mouse_exited"> <description> - Emitted when the mouse cursor exits the [Window]'s area (including when it's hovered over another window on top of this one). + Emitted when the mouse cursor leaves the [Window]'s visible area, that is not occluded behind other [Control]s or windows, provided its [member Viewport.gui_disable_input] is [code]false[/code] and regardless if it's currently focused or not. </description> </signal> <signal name="theme_changed"> |