From 86aa79733bf20d0ac7cd668ee0e04f32b6a4f687 Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Wed, 21 Feb 2024 23:54:22 -0500 Subject: [PATCH] Close context panes and tab menus on Escape --- src/app.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/app.rs b/src/app.rs index cfab873..8e07f6a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -575,6 +575,22 @@ impl Application for App { Command::none() } + fn on_escape(&mut self) -> Command { + let entity = self.tab_model.active(); + + // Close menus and context panes in order per message + // Why: It'd be weird to close everything all at once + // Usually, the Escape key (for example) closes menus and panes one by one instead + // of closing everything on one press + // TODO: Close MenuBar too + match self.tab_model.data_mut::(entity) { + Some(tab) if tab.context_menu.is_some() => tab.context_menu = None, + _ => self.core.window.show_context = false, + } + + Command::none() + } + /// Handle application events here. fn update(&mut self, message: Self::Message) -> Command { // Helper for updating config values efficiently