1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Accessibility: Fix hit test behaviour on iOS

This commit is contained in:
reuk 2022-06-30 15:26:20 +01:00
parent 12fdf6bad8
commit 285761c56c
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -50,8 +50,6 @@ static NSArray* getContainerAccessibilityElements (AccessibilityHandler& handler
NSMutableArray* accessibleChildren = [NSMutableArray arrayWithCapacity: (NSUInteger) children.size()];
[accessibleChildren addObject: (id) handler.getNativeImplementation()];
for (auto* childHandler : children)
{
id accessibleElement = [&childHandler]
@ -68,6 +66,8 @@ static NSArray* getContainerAccessibilityElements (AccessibilityHandler& handler
[accessibleChildren addObject: accessibleElement];
}
[accessibleChildren addObject: (id) handler.getNativeImplementation()];
return accessibleChildren;
}
@ -186,7 +186,21 @@ private:
AccessibilityElement (Type elementType)
{
addMethod (@selector (isAccessibilityElement), getIsAccessibilityElement);
addMethodWithReturn<BOOL> (@selector (isAccessibilityElement), [] (id self, SEL)
{
auto* handler = getHandler (self);
if (handler == nullptr)
return false;
return ! handler->isIgnored()
&& handler->getRole() != AccessibilityRole::window
&& (handler->getTitle().isNotEmpty()
|| handler->getDescription().isNotEmpty()
|| handler->getHelp().isNotEmpty()
|| handler->getValueInterface() != nullptr);
});
addMethod (@selector (accessibilityContainer), getAccessibilityContainer);
addMethod (@selector (accessibilityFrame), getAccessibilityFrame);
addMethod (@selector (accessibilityTraits), getAccessibilityTraits);
@ -235,6 +249,9 @@ private:
}
private:
template <typename Return, typename Method>
void addMethodWithReturn (SEL selector, Method method) { addMethod (selector, static_cast<Return (*) (id, SEL)> (method)); }
//==============================================================================
static UIAccessibilityElement* getContainer (id self)
{