@@ -114,6 +114,10 @@ pub enum DomEventKind {
114114 KeyUp ,
115115 Input ,
116116 Ime ,
117+ Focus ,
118+ Blur ,
119+ FocusIn ,
120+ FocusOut ,
117121}
118122impl DomEventKind {
119123 pub fn discriminant ( self ) -> u8 {
@@ -141,6 +145,10 @@ impl FromStr for DomEventKind {
141145 "keyup" => Ok ( Self :: KeyUp ) ,
142146 "input" => Ok ( Self :: Input ) ,
143147 "composition" => Ok ( Self :: Ime ) ,
148+ "focus" => Ok ( Self :: Focus ) ,
149+ "blur" => Ok ( Self :: Blur ) ,
150+ "focusin" => Ok ( Self :: FocusIn ) ,
151+ "focusout" => Ok ( Self :: FocusOut ) ,
144152 _ => Err ( ( ) ) ,
145153 }
146154 }
@@ -166,6 +174,10 @@ pub enum DomEventData {
166174 KeyUp ( BlitzKeyEvent ) ,
167175 Input ( BlitzInputEvent ) ,
168176 Ime ( BlitzImeEvent ) ,
177+ Focus ( BlitzFocusEvent ) ,
178+ Blur ( BlitzFocusEvent ) ,
179+ FocusIn ( BlitzFocusEvent ) ,
180+ FocusOut ( BlitzFocusEvent ) ,
169181}
170182impl DomEventData {
171183 pub fn discriminant ( & self ) -> u8 {
@@ -197,6 +209,10 @@ impl DomEventData {
197209 Self :: KeyUp { .. } => "keyup" ,
198210 Self :: Input { .. } => "input" ,
199211 Self :: Ime { .. } => "composition" ,
212+ Self :: Focus { .. } => "focus" ,
213+ Self :: Blur { .. } => "blur" ,
214+ Self :: FocusIn { .. } => "focusin" ,
215+ Self :: FocusOut { .. } => "focusout" ,
200216 }
201217 }
202218
@@ -219,6 +235,10 @@ impl DomEventData {
219235 Self :: KeyUp { .. } => DomEventKind :: KeyUp ,
220236 Self :: Input { .. } => DomEventKind :: Input ,
221237 Self :: Ime { .. } => DomEventKind :: Ime ,
238+ Self :: Focus { .. } => DomEventKind :: Focus ,
239+ Self :: Blur { .. } => DomEventKind :: Blur ,
240+ Self :: FocusIn { .. } => DomEventKind :: FocusIn ,
241+ Self :: FocusOut { .. } => DomEventKind :: FocusOut ,
222242 }
223243 }
224244
@@ -241,6 +261,10 @@ impl DomEventData {
241261 Self :: KeyPress { .. } => true ,
242262 Self :: Ime { .. } => true ,
243263 Self :: Input { .. } => false ,
264+ Self :: Focus { .. } => false ,
265+ Self :: Blur { .. } => false ,
266+ Self :: FocusIn { .. } => false ,
267+ Self :: FocusOut { .. } => false ,
244268 }
245269 }
246270
@@ -263,6 +287,10 @@ impl DomEventData {
263287 Self :: KeyPress { .. } => true ,
264288 Self :: Ime { .. } => true ,
265289 Self :: Input { .. } => true ,
290+ Self :: Focus { .. } => false ,
291+ Self :: Blur { .. } => false ,
292+ Self :: FocusIn { .. } => true ,
293+ Self :: FocusOut { .. } => true ,
266294 }
267295 }
268296}
@@ -400,6 +428,9 @@ pub struct BlitzInputEvent {
400428 pub value : String ,
401429}
402430
431+ #[ derive( Clone , Debug ) ]
432+ pub struct BlitzFocusEvent ;
433+
403434/// Copy of Winit IME event to avoid lower-level Blitz crates depending on winit
404435#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
405436pub enum BlitzImeEvent {
0 commit comments