mirror of
https://github.com/hubaldv/bioz-host-rs.git
synced 2026-07-24 00:57:44 +00:00
Change tabs depending on TCP input.
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
22
src/app.rs
22
src/app.rs
@@ -48,10 +48,19 @@ pub enum TabActive {
|
||||
Shortcuts,
|
||||
}
|
||||
|
||||
impl ToString for TabActive {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
TabActive::Single => "Single".to_string(),
|
||||
TabActive::Sweep => "Sweep".to_string(),
|
||||
TabActive::Shortcuts => "Shortcuts".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
tree: DockState<String>,
|
||||
tab_viewer: CustomTabs,
|
||||
// tab_active: TabActive,
|
||||
log_filename: Arc<Mutex<String>>,
|
||||
log_marker_modal: bool,
|
||||
log_marker: String,
|
||||
@@ -865,6 +874,17 @@ impl eframe::App for App {
|
||||
.show_inside(ui, &mut self.tab_viewer);
|
||||
});
|
||||
|
||||
// Check if tab is different from the active tab in app state, if so, switch to that tab
|
||||
if let Some((_, name)) = self.tree.find_active_focused() {
|
||||
if self.app_state_rx.borrow().tab_active.to_string() != *name {
|
||||
let active_tab = self.app_state_rx.borrow().tab_active.to_string();
|
||||
self.tree.set_active_tab(self.tree.find_tab(&active_tab).unwrap());
|
||||
}
|
||||
} else {
|
||||
let active_tab = self.app_state_rx.borrow().tab_active.to_string();
|
||||
self.tree.set_active_tab(self.tree.find_tab(&active_tab).unwrap());
|
||||
}
|
||||
|
||||
// CMD- or control-W to close window
|
||||
if ctx.input(|i| i.modifiers.cmd_ctrl_matches(Modifiers::COMMAND))
|
||||
&& ctx.input(|i| i.key_pressed(Key::W))
|
||||
|
||||
Reference in New Issue
Block a user