@@ -20,12 +20,26 @@ pub struct NxShellOptions {
2020 pub show_add_session_modal : Rc < RefCell < bool > > ,
2121 pub show_dock_panel : bool ,
2222 pub multi_exec : bool ,
23+ /// Id of active tab
24+ ///
25+ /// Its main purpose is to preserve the state of egui::Response::contains_pointer().
26+ /// Its functions :
27+ ///
28+ /// 1. When the mouse cursor leaves the terminal, it still influences the state of the current
29+ /// terminal's selection.
30+ /// 2. When it is None, all tabs lose focus, and you can iteract with the other UI components.
2331 pub active_tab_id : Option < Id > ,
2432 pub term_font : TerminalFont ,
2533 pub term_font_size : f32 ,
2634 pub session_filter : String ,
2735}
2836
37+ impl NxShellOptions {
38+ pub fn surrender_focus ( & mut self ) {
39+ self . active_tab_id = None ;
40+ }
41+ }
42+
2943impl Default for NxShellOptions {
3044 fn default ( ) -> Self {
3145 let term_font_size = 14. ;
@@ -130,13 +144,14 @@ impl eframe::App for NxShell {
130144 } ) ;
131145
132146 if * self . opts . show_add_session_modal . borrow ( ) {
147+ self . opts . surrender_focus ( ) ;
133148 self . show_add_session_window ( ctx, & mut toasts) ;
134- } else {
135- egui:: CentralPanel :: default ( ) . show ( ctx, |_ui| {
136- self . tab_view ( ctx) ;
137- } ) ;
138149 }
139150
151+ egui:: CentralPanel :: default ( ) . show ( ctx, |_ui| {
152+ self . tab_view ( ctx) ;
153+ } ) ;
154+
140155 toasts. show ( ctx) ;
141156 }
142157}
@@ -146,8 +161,7 @@ impl NxShell {
146161 let text_edit = TextEdit :: singleline ( & mut self . opts . session_filter ) ;
147162 let response = ui. add ( text_edit) ;
148163 if response. clicked ( ) {
149- // gain ui focus
150- self . opts . active_tab_id = None ;
164+ self . opts . surrender_focus ( ) ;
151165 } else if response. changed ( ) {
152166 if let Ok ( sessions) = self . db . find_sessions ( & self . opts . session_filter ) {
153167 self . state_manager . sessions = Some ( sessions) ;
0 commit comments