File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,14 @@ impl<'a> Node<'a> {
413
413
} )
414
414
}
415
415
416
+ pub fn is_dialog ( & self ) -> bool {
417
+ matches ! ( self . role( ) , Role :: AlertDialog | Role :: Dialog )
418
+ }
419
+
420
+ pub fn is_modal ( & self ) -> bool {
421
+ self . data ( ) . is_modal ( )
422
+ }
423
+
416
424
// When probing for supported actions as the next several functions do,
417
425
// it's tempting to check the role. But it's better to not assume anything
418
426
// beyond what the provider has explicitly told us. Rationale:
Original file line number Diff line number Diff line change @@ -221,6 +221,17 @@ impl State {
221
221
self . focus_id ( ) . map ( |id| self . node_by_id ( id) . unwrap ( ) )
222
222
}
223
223
224
+ pub fn active_dialog ( & self ) -> Option < Node < ' _ > > {
225
+ let mut node = self . focus ( ) ;
226
+ while let Some ( candidate) = node {
227
+ if candidate. is_dialog ( ) {
228
+ return Some ( candidate) ;
229
+ }
230
+ node = candidate. parent ( ) ;
231
+ }
232
+ None
233
+ }
234
+
224
235
pub fn toolkit_name ( & self ) -> Option < & str > {
225
236
self . data . toolkit_name . as_deref ( )
226
237
}
You can’t perform that action at this time.
0 commit comments