Skip to content

Commit 6307b0b

Browse files
committed
Dismiss currently visible or upcoming tooltips when pressing Escape
This is standard UI behavior in most applications out there.
1 parent faaf27f commit 6307b0b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scene/main/viewport.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,18 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
21842184
return;
21852185
}
21862186

2187+
if (p_event->is_action_pressed("ui_cancel")) {
2188+
// Cancel tooltip timer or hide tooltip when pressing Escape (this is standard behavior in most applications).
2189+
_gui_cancel_tooltip();
2190+
if (gui.tooltip_popup) {
2191+
// If a tooltip was hidden, prevent other actions associated with `ui_cancel` from occurring.
2192+
// For instance, this prevents the node from being deselected when pressing Escape
2193+
// to hide a documentation tooltip in the inspector.
2194+
set_input_as_handled();
2195+
return;
2196+
}
2197+
}
2198+
21872199
if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
21882200
gui.key_focus->release_focus();
21892201
}

0 commit comments

Comments
 (0)