From 5ae6382105c2593e0e224048b319bb664d103c53 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Apr 2024 14:22:47 -0700 Subject: [PATCH] Allow closing scene tab preview using Escape --- editor/gui/editor_scene_tabs.cpp | 12 ++++++++++++ editor/gui/editor_scene_tabs.h | 1 + 2 files changed, 13 insertions(+) diff --git a/editor/gui/editor_scene_tabs.cpp b/editor/gui/editor_scene_tabs.cpp index b6cb3d73719..5d1e68f0082 100644 --- a/editor/gui/editor_scene_tabs.cpp +++ b/editor/gui/editor_scene_tabs.cpp @@ -135,6 +135,17 @@ void EditorSceneTabs::_scene_tab_input(const Ref &p_input) { } } +void EditorSceneTabs::unhandled_key_input(const Ref &p_event) { + if (!tab_preview_panel->is_visible()) { + return; + } + + Ref k = p_event; + if (k.is_valid() && k->is_action_pressed(SNAME("ui_cancel"), false, true)) { + tab_preview_panel->hide(); + } +} + void EditorSceneTabs::_reposition_active_tab(int p_to_index) { EditorNode::get_editor_data().move_edited_scene_to_index(p_to_index); update_scene_tabs(); @@ -369,6 +380,7 @@ EditorSceneTabs::EditorSceneTabs() { singleton = this; set_process_shortcut_input(true); + set_process_unhandled_key_input(true); tabbar_panel = memnew(PanelContainer); add_child(tabbar_panel); diff --git a/editor/gui/editor_scene_tabs.h b/editor/gui/editor_scene_tabs.h index 770114835a5..ac9e6b8c432 100644 --- a/editor/gui/editor_scene_tabs.h +++ b/editor/gui/editor_scene_tabs.h @@ -79,6 +79,7 @@ class EditorSceneTabs : public MarginContainer { protected: void _notification(int p_what); + virtual void unhandled_key_input(const Ref &p_event) override; static void _bind_methods(); public: