Skip to content

Commit

Permalink
Merge pull request #80364 from Calinou/control-escape-dismiss-tooltips
Browse files Browse the repository at this point in the history
Dismiss currently visible or upcoming tooltips when pressing Escape
  • Loading branch information
akien-mga committed Aug 8, 2023
2 parents 1163dac + 6307b0b commit 46c9a14
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,18 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
return;
}

if (p_event->is_action_pressed("ui_cancel")) {
// Cancel tooltip timer or hide tooltip when pressing Escape (this is standard behavior in most applications).
_gui_cancel_tooltip();
if (gui.tooltip_popup) {
// 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.
set_input_as_handled();
return;
}
}

if (gui.key_focus && !gui.key_focus->is_visible_in_tree()) {
gui.key_focus->release_focus();
}
Expand Down

0 comments on commit 46c9a14

Please sign in to comment.