mirror of https://github.com/encounter/objdiff.git
Add Ctrl+F/S shortcuts for focusing the object and symbol filter text edits
This commit is contained in:
parent
5de087c903
commit
0143046f3f
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue