@@ -3,8 +3,8 @@ use std::{collections::HashMap, sync::Arc};
3
3
use bimap:: BiMap ;
4
4
use chrono:: { Duration , Timelike } ;
5
5
use eframe:: egui:: {
6
- self , text:: LayoutJob , CursorIcon , Key , Label , LayerId , Modifiers , Rect ,
7
- Response , Sense , Ui ,
6
+ self , text:: LayoutJob , CursorIcon , EventFilter , Key , KeyboardShortcut , Label ,
7
+ LayerId , Modifiers , Rect , Response , Sense , Ui ,
8
8
} ;
9
9
use egui_autocomplete:: AutoCompleteTextEdit ;
10
10
use humantime;
@@ -490,9 +490,9 @@ impl ScheduleUi {
490
490
}
491
491
492
492
pub ( super ) fn handle_hotkeys ( & mut self , ui : & Ui ) {
493
- self . handle_keyboard_focus_move ( ui) ;
494
- self . handle_keyboard_focused_event_move ( ui) ;
495
493
self . handle_keyboard_focused_event_resize ( ui) ;
494
+ self . handle_keyboard_focused_event_move ( ui) ;
495
+ self . handle_keyboard_focus_move ( ui) ;
496
496
self . handle_keyboard_new_event ( ui) ;
497
497
self . handle_keyboard_delete_event ( ui) ;
498
498
}
@@ -503,7 +503,9 @@ impl ScheduleUi {
503
503
modifiers : Modifiers ,
504
504
) -> Option < Direction > {
505
505
use Direction :: * ;
506
- let pressed = |k| ui. input_mut ( |input| input. consume_key ( modifiers, k) ) ;
506
+ let shortcut = |k| KeyboardShortcut :: new ( modifiers, k) ;
507
+ let pressed =
508
+ |k| ui. input_mut ( |input| input. consume_shortcut ( & shortcut ( k) ) ) ;
507
509
508
510
// do not interrupt interacting events
509
511
if InteractingEvent :: is_interacting ( ui) {
@@ -694,6 +696,7 @@ impl ScheduleUi {
694
696
695
697
let button = egui:: Button :: new ( layout) . sense ( Sense :: click_and_drag ( ) ) ;
696
698
let resp = ui. put ( rect, button) ;
699
+ disable_built_in_keyboard_focus_navigation ( & resp) ;
697
700
698
701
if clipped {
699
702
// text is clipped, show a tooltip
@@ -802,9 +805,10 @@ impl ScheduleUi {
802
805
let editor = AutoCompleteTextEdit :: new ( & mut event. title , & candidates)
803
806
. max_suggestions ( 5 )
804
807
. highlight_matches ( true ) ;
805
- // uncomment the following to use pure egui textedit
806
808
809
+ // uncomment the following to use pure egui textedit
807
810
// let editor = egui::TextEdit::singleline(&mut event.title);
811
+
808
812
let resp = ui. put ( rect, editor) ;
809
813
810
814
// Anything dragging outside the textedit should be equivalent to
@@ -826,6 +830,7 @@ impl ScheduleUi {
826
830
}
827
831
828
832
resp. request_focus ( ) ;
833
+ disable_built_in_keyboard_focus_navigation ( & resp) ;
829
834
None
830
835
}
831
836
@@ -1125,3 +1130,16 @@ fn find_adjacent_event(
1125
1130
1126
1131
Some ( events[ new_i as usize ] . id . clone ( ) )
1127
1132
}
1133
+
1134
+ fn disable_built_in_keyboard_focus_navigation ( resp : & Response ) {
1135
+ // avoid built-in arrow navigation
1136
+ let event_filter = EventFilter {
1137
+ horizontal_arrows : true ,
1138
+ vertical_arrows : true ,
1139
+ ..Default :: default ( )
1140
+ } ;
1141
+
1142
+ resp
1143
+ . ctx
1144
+ . memory_mut ( |m| m. set_focus_lock_filter ( resp. id , event_filter) ) ;
1145
+ }
0 commit comments