Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visibility matching on SLElement #232

Conversation

plantpurecode
Copy link

Added functionality to SLElement which further filters the matching routine based on the visibility of a view.

@@ -135,6 +135,13 @@ - (BOOL)matchesObject:(NSObject *)object
NSAssert(_matchesObject, @"matchesObject called on %@, which has no _matchesObject predicate", self);
BOOL matchesObject = _matchesObject(object);

// Non-UIView objects are assumed to be "not hidden"
if (self.matchOnlyIfVisible) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd want to use -[NSObject slAccessibilityIsVisible], and check all objects, here--there are a bunch of reasons why objects, including non-views, might not be visible from both the user's and UIAutomation's perspectives.

(Making this change would cause matchOnlyIfVisible to fail in non-portrait orientations (#135), but would be generally more robust. It would be nice if you could fall back to UIAElement.isVisible as does -[SLElement isVisible] but I'm not sure how you'd do that given that matching takes place on the main thread.)

@wearhere
Copy link
Contributor

Is the scenario here that you have two elements in the hierarchy with the same attributes, only one is visible and one isn't? How often would you say this comes up? An alternative to building this functionality into SLElement would be to use -elementMatching: as shown here.

@plantpurecode
Copy link
Author

Will use -[NSObject slAccessibilityIsVisible], thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants