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

WebBrowserComponent: iOS: Add accessibility integration

This commit is contained in:
attila 2023-04-27 15:27:31 +02:00 committed by Attila Szarvas
parent f519af3b62
commit 18489bb7d7
4 changed files with 32 additions and 7 deletions

View file

@ -277,7 +277,8 @@ private:
if (handler->getComponent().isOnDesktop())
return static_cast<id> (handler->getComponent().getWindowHandle());
if (! handler->getChildren().empty())
if ( ! handler->getChildren().empty()
|| AccessibilityHandler::getNativeChildForComponent (handler->getComponent()) != nullptr)
{
if (UIAccessibilityElement* container = getContainer (self))
return container;

View file

@ -56,19 +56,31 @@ static NSArray* getContainerAccessibilityElements (AccessibilityHandler& handler
{
id accessibleElement = [&childHandler]
{
id native = static_cast<id> (childHandler->getNativeImplementation());
id nativeChild = static_cast<id> (childHandler->getNativeImplementation());
if (! childHandler->getChildren().empty())
return [native accessibilityContainer];
if ( ! childHandler->getChildren().empty()
|| AccessibilityHandler::getNativeChildForComponent (childHandler->getComponent()) != nullptr)
{
return [nativeChild accessibilityContainer];
}
return native;
return nativeChild;
}();
if (accessibleElement != nil)
[accessibleChildren addObject: accessibleElement];
}
[accessibleChildren addObject: static_cast<id> (handler.getNativeImplementation())];
id nativeHandler = static_cast<id> (handler.getNativeImplementation());
if (auto* view = static_cast<UIView*> (AccessibilityHandler::getNativeChildForComponent (handler.getComponent())))
{
[static_cast<UIAccessibilityElement*> (view) setAccessibilityContainer: [nativeHandler accessibilityContainer]];
[accessibleChildren addObject: view];
}
[accessibleChildren addObject: nativeHandler];
return accessibleChildren;
}

View file

@ -74,6 +74,8 @@ public:
//==============================================================================
/** @internal */
void paint (Graphics&) override;
/** @internal */
std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
private:

View file

@ -103,7 +103,10 @@ private:
//==============================================================================
UIViewComponent::UIViewComponent() {}
UIViewComponent::~UIViewComponent() {}
UIViewComponent::~UIViewComponent()
{
AccessibilityHandler::setNativeChildForComponent (*this, nullptr);
}
void UIViewComponent::setView (void* view)
{
@ -113,6 +116,8 @@ void UIViewComponent::setView (void* view)
if (view != nullptr)
pimpl.reset (new Pimpl ((UIView*) view, *this));
AccessibilityHandler::setNativeChildForComponent (*this, getView());
}
}
@ -129,4 +134,9 @@ void UIViewComponent::resizeToFitView()
void UIViewComponent::paint (Graphics&) {}
std::unique_ptr<AccessibilityHandler> UIViewComponent::createAccessibilityHandler()
{
return std::make_unique<AccessibilityHandler> (*this, AccessibilityRole::group);
}
} // namespace juce