diff --git a/objdiff-gui/src/hotkeys.rs b/objdiff-gui/src/hotkeys.rs index 4467ccb..d23529f 100644 --- a/objdiff-gui/src/hotkeys.rs +++ b/objdiff-gui/src/hotkeys.rs @@ -1,4 +1,6 @@ -use egui::{style::ScrollAnimation, vec2, Context, Key, Modifiers, PointerButton}; +use egui::{ + style::ScrollAnimation, vec2, Context, Key, KeyboardShortcut, Modifiers, PointerButton, +}; fn any_widget_focused(ctx: &Context) -> bool { ctx.memory(|mem| mem.focused().is_some()) } @@ -74,3 +76,15 @@ pub fn consume_down_key(ctx: &Context) -> bool { i.consume_key(Modifiers::NONE, Key::ArrowDown) || i.consume_key(Modifiers::NONE, Key::S) }) } + +const OBJECT_FILTER_SHORTCUT: KeyboardShortcut = KeyboardShortcut::new(Modifiers::CTRL, Key::F); + +pub fn consume_object_filter_shortcut(ctx: &Context) -> bool { + ctx.input_mut(|i| i.consume_shortcut(&OBJECT_FILTER_SHORTCUT)) +} + +const SYMBOL_FILTER_SHORTCUT: KeyboardShortcut = KeyboardShortcut::new(Modifiers::CTRL, Key::S); + +pub fn consume_symbol_filter_shortcut(ctx: &Context) -> bool { + ctx.input_mut(|i| i.consume_shortcut(&SYMBOL_FILTER_SHORTCUT)) +} diff --git a/objdiff-gui/src/views/config.rs b/objdiff-gui/src/views/config.rs index 6d7fd9e..da382de 100644 --- a/objdiff-gui/src/views/config.rs +++ b/objdiff-gui/src/views/config.rs @@ -21,6 +21,7 @@ use strum::{EnumMessage, VariantArray}; use crate::{ app::{AppConfig, AppState, AppStateRef, ObjectConfig}, config::ProjectObjectNode, + hotkeys, jobs::{ check_update::{start_check_update, CheckUpdateResult}, update::start_update, @@ -254,7 +255,11 @@ pub fn config_ui( } } else { let had_search = !config_state.object_search.is_empty(); - egui::TextEdit::singleline(&mut config_state.object_search).hint_text("Filter").ui(ui); + let response = + egui::TextEdit::singleline(&mut config_state.object_search).hint_text("Filter").ui(ui); + if hotkeys::consume_object_filter_shortcut(ui.ctx()) { + response.request_focus(); + } let mut root_open = None; let mut node_open = NodeOpen::Default; diff --git a/objdiff-gui/src/views/symbol_diff.rs b/objdiff-gui/src/views/symbol_diff.rs index 0041e92..0a9fb4a 100644 --- a/objdiff-gui/src/views/symbol_diff.rs +++ b/objdiff-gui/src/views/symbol_diff.rs @@ -898,7 +898,11 @@ pub fn symbol_diff_ui( }); let mut search = state.search.clone(); - if TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui).changed() { + let response = TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui); + if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) { + response.request_focus(); + } + if response.changed() { ret = Some(DiffViewAction::SetSearch(search)); } } else if column == 1 {