@@ -21,62 +21,7 @@ struct App {
2121 window : Option < Box < dyn Window > > ,
2222}
2323
24- use winit:: event:: KeyEvent ;
25- use winit_core:: keyboard:: Modifiers ;
2624// https://docs.rs/winit/latest/winit/event/struct.Modifiers.html
27- pub fn mod_state_side_aware_s ( mods : & Modifiers ) -> String {
28- let mut s = String :: new ( ) ;
29- if mods. lshift_state ( ) {
30- s. push_str ( "‹⇧" ) ;
31- if mods. rshift_state ( ) {
32- s. push ( '›' )
33- } else {
34- s. push ( ' ' )
35- } ;
36- } else if mods. rshift_state ( ) {
37- s. push_str ( " ⇧›" )
38- } else {
39- s. push_str ( " " )
40- }
41- if mods. lcontrol_state ( ) {
42- s. push_str ( "‹⎈" ) ;
43- if mods. rcontrol_state ( ) {
44- s. push ( '›' )
45- } else {
46- s. push ( ' ' )
47- } ;
48- } else if mods. rcontrol_state ( ) {
49- s. push_str ( " ⎈›" )
50- } else {
51- s. push_str ( " " )
52- }
53- if mods. lmeta_state ( ) {
54- s. push_str ( "‹◆" ) ;
55- if mods. rmeta_state ( ) {
56- s. push ( '›' )
57- } else {
58- s. push ( ' ' )
59- } ;
60- } else if mods. rmeta_state ( ) {
61- s. push_str ( " ◆›" )
62- } else {
63- s. push_str ( " " )
64- }
65- if mods. lalt_state ( ) {
66- s. push_str ( "‹⎇" ) ;
67- if mods. ralt_state ( ) {
68- s. push ( '›' )
69- } else {
70- s. push ( ' ' )
71- } ;
72- } else if mods. ralt_state ( ) {
73- s. push_str ( " ⎇›" )
74- } else {
75- s. push_str ( " " )
76- }
77- s. push_str ( " " ) ;
78- s
79- }
8025// pub struct KeyEvent
8126// physical_key: PhysicalKey, enum PhysicalKey
8227// Code ( KeyCode)
@@ -90,7 +35,7 @@ pub fn mod_state_side_aware_s(mods: &Modifiers) -> String {
9035// location: KeyLocation, enum KeyLocation Standard,Left,Right,Numpad
9136// state : ElementState, pressed/released
9237//🔁repeat : bool
93- use winit:: event:: ElementState ;
38+ use winit:: event:: { ElementState , KeyEvent } ;
9439use winit:: keyboard:: { Key , KeyLocation , PhysicalKey } ;
9540pub fn ev_key_s ( key : & KeyEvent ) -> String {
9641 let mut s = String :: new ( ) ;
@@ -166,8 +111,7 @@ impl ApplicationHandler for App {
166111 fn window_event ( & mut self , event_loop : & dyn ActiveEventLoop , _: WindowId , event : WindowEvent ) {
167112 match event {
168113 WindowEvent :: ModifiersChanged ( mods) => {
169- let pressed_mods_s = mod_state_side_aware_s ( & mods) ;
170- println ! ( "Δ {}\t modifier state" , pressed_mods_s) ;
114+ println ! ( "Δ {mods}\t modifier state" ) ;
171115 } ,
172116 WindowEvent :: KeyboardInput { event, is_synthetic, .. } => {
173117 let is_synthetic_s = if is_synthetic { "⚗" } else { " " } ;
0 commit comments