@@ -6,12 +6,11 @@ use accessibility::{AXAttribute, AXUIElement, AXUIElementAttributes};
66use accessibility_sys:: {
77 AXUIElementCopyMultipleAttributeValues , AXValueCreate , AXValueGetValue , AXValueRef ,
88 kAXButtonRole, kAXCellRole, kAXCheckBoxRole, kAXComboBoxRole, kAXContentListSubrole,
9- kAXErrorSuccess, kAXGroupRole, kAXHiddenAttribute, kAXImageRole, kAXListRole,
10- kAXMenuButtonRole, kAXMenuItemRole, kAXMenuRole, kAXPopUpButtonRole, kAXPositionAttribute,
11- kAXPressAction, kAXRoleAttribute, kAXRowRole, kAXScrollAreaRole, kAXScrollBarRole,
12- kAXSelectedTextRangeAttribute, kAXSizeAttribute, kAXStaticTextRole, kAXTextAreaRole,
13- kAXTextFieldRole, kAXTitleAttribute, kAXValueTypeCFRange, kAXValueTypeCGPoint,
14- kAXValueTypeCGSize, kAXWindowRole,
9+ kAXErrorSuccess, kAXGroupRole, kAXHiddenAttribute, kAXImageRole, kAXListRole, kAXMenuItemRole,
10+ kAXMenuRole, kAXPopUpButtonRole, kAXPositionAttribute, kAXPressAction, kAXRoleAttribute,
11+ kAXRowRole, kAXScrollAreaRole, kAXScrollBarRole, kAXSelectedTextRangeAttribute,
12+ kAXSizeAttribute, kAXStaticTextRole, kAXTextAreaRole, kAXTextFieldRole, kAXTitleAttribute,
13+ kAXValueTypeCFRange, kAXValueTypeCGPoint, kAXValueTypeCGSize, kAXWindowRole,
1514} ;
1615use core_foundation:: {
1716 array:: { CFArray , CFArrayRef } ,
@@ -35,7 +34,8 @@ pub enum ElementSignal {
3534 // Traversal
3635 ElementFound ( Option < ElementOfInterest > ) ,
3736 TraversalFinished ( Target ) ,
38- ClearOnPopUp ,
37+ StartPopup ,
38+ EndPopup ,
3939}
4040
4141fn match_helper ( pattern : & str , value : & impl ToString ) -> bool {
@@ -834,7 +834,7 @@ fn traverse_elements(
834834 } ;
835835
836836 let mut window_frame = * window_frame;
837- let mut finish_early = false ;
837+ let mut is_popup = false ;
838838
839839 #[ allow( non_upper_case_globals) ]
840840 match ele_fp. role . as_str ( ) {
@@ -1027,8 +1027,8 @@ fn traverse_elements(
10271027 }
10281028 }
10291029 kAXGroupRole if element. subrole ( ) . is_ok_and ( |r| r == "AXApplicationDialog" ) => {
1030- let _ = result_tx. send ( ElementSignal :: ClearOnPopUp ) ;
1031- finish_early = true ;
1030+ let _ = result_tx. send ( ElementSignal :: StartPopup ) ;
1031+ is_popup = true ;
10321032 }
10331033 kAXGroupRole => match target {
10341034 Target :: Clickable if element. is_clickable ( ) => {
@@ -1050,14 +1050,9 @@ fn traverse_elements(
10501050 }
10511051 _ => ( ) ,
10521052 } ,
1053- kAXMenuRole
1054- if element
1055- . parent ( )
1056- . and_then ( |p| p. role ( ) )
1057- . is_ok_and ( |r| r == kAXMenuButtonRole) =>
1058- {
1059- let _ = result_tx. send ( ElementSignal :: ClearOnPopUp ) ;
1060- finish_early = true ;
1053+ kAXMenuRole => {
1054+ let _ = result_tx. send ( ElementSignal :: StartPopup ) ;
1055+ is_popup = true ;
10611056 }
10621057 kAXMenuItemRole => match target {
10631058 Target :: Text => {
@@ -1123,8 +1118,8 @@ fn traverse_elements(
11231118 depth + 1 ,
11241119 ) ;
11251120 }
1126- if finish_early {
1127- let _ = result_tx. send ( ElementSignal :: TraversalFinished ( target . clone ( ) ) ) ;
1121+ if is_popup {
1122+ let _ = result_tx. send ( ElementSignal :: EndPopup ) ;
11281123 }
11291124 }
11301125}
0 commit comments