Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix tooltip reappearing after dismiss with Escape

Geordie -60474cdf1183
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index fb280e1132f..45a2677f9e6 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2307,8 +2307,13 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (p_event->is_action_pressed(SNAME("ui_cancel"))) {
// Cancel tooltip timer or hide tooltip when pressing Escape (this is standard behavior in most applications).
+ Control *tooltip_control = gui.tooltip_control;
_gui_cancel_tooltip();
if (gui.tooltip_popup) {
+ // Some platforms send a mouse motion event when the tooltip is destroyed under the cursor.
+ // Remember the tooltip control, so that the tooltip timer is not immediately restarted
+ // by a mouse event triggered upon the tooltip closing.
+ gui.tooltip_control = tooltip_control;
// If a tooltip was hidden, prevent other actions associated with `ui_cancel` from occurring.
// For instance, this prevents the node from being deselected when pressing Escape
// to hide a documentation tooltip in the inspector.