@@ -857,8 +857,8 @@ impl MyApp {
857857 ui. label ( t ! ( "lbl.resumed" , lang) ) ;
858858 }
859859 let b = ui. button ( text) ;
860- // b.ctx.set_style(style);
861- if ( b. clicked ( ) || ui. input ( |i| i. key_pressed ( egui:: Key :: Space ) ) )
860+
861+ if ( b. clicked ( ) || ui. input_mut ( |i| i. consume_key ( egui :: Modifiers :: NONE , egui:: Key :: Space ) ) )
862862 && !editor_focused
863863 {
864864 if self . tm . finished ( ) {
@@ -894,28 +894,24 @@ impl eframe::App for MyApp {
894894 let lang = self . get_lang ( ) ;
895895 let mut editor_focused = false ;
896896
897- ctx. input ( |i| {
898- let ctrl_pressed = i. modifiers . ctrl || i. modifiers . command ;
899-
897+ ctx. input_mut ( |i| {
900898 // Check for keyboard shortcuts
901- if ctrl_pressed {
902- if i. key_down ( egui:: Key :: S ) {
903- // Ctrl+S
904- debug ! ( "Saving..." ) ;
905- self . save_file ( ) ;
906- } else if i. key_down ( egui:: Key :: O ) {
907- // Ctrl+O
908- debug ! ( "Opening..." ) ;
909- self . load_file ( ) ;
910- } else if i. modifiers . shift && i. key_down ( egui:: Key :: S ) {
911- // Ctrl+Shift+S
912- debug ! ( "Saving as..." ) ;
913- self . save_file_as ( ) ;
914- } else if i. key_down ( egui:: Key :: R ) {
915- // Ctrl+R
916- debug ! ( "Restarting..." ) ;
917- self . tm = self . tm . restart ( & self . code ) . unwrap ( ) ;
918- }
899+ if i. consume_shortcut ( & egui:: KeyboardShortcut :: new ( egui:: Modifiers :: COMMAND , egui:: Key :: S ) ) {
900+ // Ctrl+S
901+ debug ! ( "Saving..." ) ;
902+ self . save_file ( ) ;
903+ } else if i. consume_shortcut ( & egui:: KeyboardShortcut :: new ( egui:: Modifiers :: COMMAND , egui:: Key :: O ) ) {
904+ // Ctrl+O
905+ debug ! ( "Opening..." ) ;
906+ self . load_file ( ) ;
907+ } else if i. modifiers . shift && i. consume_shortcut ( & egui:: KeyboardShortcut :: new ( egui:: Modifiers :: CTRL , egui:: Key :: S ) ) {
908+ // Ctrl+Shift+S
909+ debug ! ( "Saving as..." ) ;
910+ self . save_file_as ( ) ;
911+ } else if i. consume_shortcut ( & egui:: KeyboardShortcut :: new ( egui:: Modifiers :: COMMAND , egui:: Key :: R ) ) {
912+ // Ctrl+R
913+ debug ! ( "Restarting..." ) ;
914+ self . tm = self . tm . restart ( & self . code ) . unwrap ( ) ;
919915 }
920916 } ) ;
921917
0 commit comments