diff --git a/tui/src/float.rs b/tui/src/float.rs index 4d6ac006..af836175 100644 --- a/tui/src/float.rs +++ b/tui/src/float.rs @@ -4,6 +4,8 @@ use ratatui::{ Frame, }; +use crate::event::MouseButton; +use crate::event::MouseEventKind; use crate::hint::Shortcut; pub trait FloatContent { @@ -54,8 +56,11 @@ impl Float { self.content.draw(frame, popup_area); } - pub fn handle_mouse_event(&mut self, event: &MouseEvent) { - self.content.handle_mouse_event(event); + pub fn handle_mouse_event(&mut self, event: &MouseEvent) -> bool { + match event.kind { + MouseEventKind::Down(MouseButton::Right) => true, + _ => self.content.handle_mouse_event(event), + } } // Returns true if the floating window is finished. diff --git a/tui/src/state.rs b/tui/src/state.rs index 2da2eb69..eaa582a7 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -495,6 +495,23 @@ impl AppState { return true; } + match &mut self.focus { + Focus::FloatingWindow(float) => { + if float.handle_mouse_event(event) { + self.focus = Focus::List; + } + return true; + } + Focus::ConfirmationPrompt(prompt) => { + if prompt.handle_mouse_event(event) { + self.focus = Focus::List; + self.selected_commands.clear(); + } + return true; + } + _ => {} + } + if matches!(self.focus, Focus::TabList | Focus::List | Focus::Search) { let position = Position::new(event.column, event.row); let mouse_in_tab_list = self.areas.as_ref().unwrap().tab_list.contains(position); @@ -561,7 +578,7 @@ impl AppState { if matches!(self.focus, Focus::Search) { self.exit_search(); } - self.focus = Focus::List; + self.focus = Focus::TabList; } } MouseButton::Right if mouse_in_list => { @@ -598,15 +615,6 @@ impl AppState { _ => {} } } - match &mut self.focus { - Focus::FloatingWindow(float) => { - float.content.handle_mouse_event(event); - } - Focus::ConfirmationPrompt(confirm) => { - confirm.content.handle_mouse_event(event); - } - _ => {} - } true }