irongit

style: hide mouse hover effects with keyboard interaction in miller views

huncholanehuncholaneauthored
parent 09b7359commit 8fd8c9dcd36e61fa92a2acfc294a8ef337a5f87fBrowse files

2 files changed, +19 -1

+4-0src/widgets/hover_row.rs
@@ -9,7 +9,11 @@ pub fn prev_frame_hover(
99 }
1010
1111 /// Check hover for a pre-computed Id.
12+/// Returns false when keyboard navigation is active (see `miller::keyboard_active`).
1213 pub fn check_hover(ctx: &egui::Context, id: egui::Id) -> (bool, egui::Id) {
14+ if super::miller::keyboard_active(ctx) {
15+ return (false, id);
16+ }
1317 let hovered = ctx.data(|d| d.get_temp::<bool>(id)).unwrap_or(false);
1418 (hovered, id)
1519 }
+15-1src/widgets/miller.rs
@@ -12,8 +12,16 @@ pub enum MillerAction {
1212 None,
1313 }
1414
15+const KEYBOARD_ACTIVE_ID: &str = "miller_keyboard_active";
16+
17+/// Returns true if keyboard navigation happened this frame (suppresses hover highlights).
18+pub fn keyboard_active(ctx: &egui::Context) -> bool {
19+ ctx.data(|d| d.get_temp::<bool>(egui::Id::new(KEYBOARD_ACTIVE_ID))).unwrap_or(false)
20+}
21+
1522 /// Read J/K/H/L/Arrow/Home/End/G keys and return the corresponding action.
1623 /// Pass `skip: true` to suppress (e.g., when a text input has focus).
24+/// When a key is pressed, hover highlights are suppressed for this frame.
1725 pub fn read_miller_keys(ui: &Ui, skip: bool) -> MillerAction {
1826 if skip {
1927 return MillerAction::None;
@@ -34,7 +42,7 @@ pub fn read_miller_keys(ui: &Ui, skip: bool) -> MillerAction {
3442 let go_top = ui.input(|i| i.key_pressed(egui::Key::G) || i.key_pressed(egui::Key::Home));
3543 let go_bottom = ui.input(|i| i.key_pressed(egui::Key::End));
3644
37- if down {
45+ let action = if down {
3846 MillerAction::Down
3947 } else if up {
4048 MillerAction::Up
@@ -48,7 +56,13 @@ pub fn read_miller_keys(ui: &Ui, skip: bool) -> MillerAction {
4856 MillerAction::GoBottom
4957 } else {
5058 MillerAction::None
59+ };
60+
61+ if action != MillerAction::None {
62+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new(KEYBOARD_ACTIVE_ID), true));
5163 }
64+
65+ action
5266 }
5367
5468 /// Apply a navigation action to a selection index.