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 @@ -415,6 +415,14 @@ impl<'a> Node<'a> {
415
415
} )
416
416
}
417
417
418
+ pub fn is_dialog ( & self ) -> bool {
419
+ matches ! ( self . role( ) , Role :: AlertDialog | Role :: Dialog )
420
+ }
421
+
422
+ pub fn is_modal ( & self ) -> bool {
423
+ self . data ( ) . is_modal ( )
424
+ }
425
+
418
426
// When probing for supported actions as the next several functions do,
419
427
// it's tempting to check the role. But it's better to not assume anything
420
428
// 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