mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
WebBrowserComponent: Windows: Add accessibility integration
This commit is contained in:
parent
6ef45eb20c
commit
7657efd227
12 changed files with 381 additions and 29 deletions
|
|
@ -28,6 +28,63 @@ namespace juce
|
|||
|
||||
AccessibilityHandler* AccessibilityHandler::currentlyFocusedHandler = nullptr;
|
||||
|
||||
class NativeChildHandler
|
||||
{
|
||||
public:
|
||||
static NativeChildHandler& getInstance()
|
||||
{
|
||||
static NativeChildHandler instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void* getNativeChild (Component& component) const
|
||||
{
|
||||
if (auto it = nativeChildForComponent.find (&component);
|
||||
it != nativeChildForComponent.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Component* getComponent (void* nativeChild) const
|
||||
{
|
||||
if (auto it = componentForNativeChild.find (nativeChild);
|
||||
it != componentForNativeChild.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void setNativeChild (Component& component, void* nativeChild)
|
||||
{
|
||||
clearComponent (component);
|
||||
|
||||
if (nativeChild != nullptr)
|
||||
{
|
||||
nativeChildForComponent[&component] = nativeChild;
|
||||
componentForNativeChild[nativeChild] = &component;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
NativeChildHandler() = default;
|
||||
|
||||
void clearComponent (Component& component)
|
||||
{
|
||||
if (auto* nativeChild = getNativeChild (component))
|
||||
componentForNativeChild.erase (nativeChild);
|
||||
|
||||
nativeChildForComponent.erase (&component);
|
||||
}
|
||||
|
||||
std::map<void*, Component*> componentForNativeChild;
|
||||
std::map<Component*, void*> nativeChildForComponent;
|
||||
};
|
||||
|
||||
AccessibilityHandler::AccessibilityHandler (Component& comp,
|
||||
AccessibilityRole accessibilityRole,
|
||||
AccessibilityActions accessibilityActions,
|
||||
|
|
@ -322,6 +379,21 @@ std::unique_ptr<AccessibilityHandler::AccessibilityNativeImpl> AccessibilityHand
|
|||
#endif
|
||||
}
|
||||
|
||||
void* AccessibilityHandler::getNativeChildForComponent (Component& component)
|
||||
{
|
||||
return NativeChildHandler::getInstance().getNativeChild (component);
|
||||
}
|
||||
|
||||
Component* AccessibilityHandler::getComponentForNativeChild (void* nativeChild)
|
||||
{
|
||||
return NativeChildHandler::getInstance().getComponent (nativeChild);
|
||||
}
|
||||
|
||||
void AccessibilityHandler::setNativeChildForComponent (Component& component, void* nativeChild)
|
||||
{
|
||||
NativeChildHandler::getInstance().setNativeChild (component, nativeChild);
|
||||
}
|
||||
|
||||
#if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED
|
||||
void AccessibilityHandler::notifyAccessibilityEvent (AccessibilityEvent) const {}
|
||||
void AccessibilityHandler::postAnnouncement (const String&, AnnouncementPriority) {}
|
||||
|
|
|
|||
|
|
@ -291,6 +291,26 @@ public:
|
|||
AccessibilityNativeHandle* getNativeImplementation() const;
|
||||
/** @internal */
|
||||
std::type_index getTypeIndex() const { return typeIndex; }
|
||||
/** @internal */
|
||||
static void clearCurrentlyFocusedHandler() { currentlyFocusedHandler = nullptr; }
|
||||
|
||||
/** @internal
|
||||
|
||||
The following functions provide the means to associate JUCE Components with OS specific
|
||||
types that provide their own accessibility mechanisms. This way accessibility navigation
|
||||
can move from a JUCE Component to a native, embedded window and back.
|
||||
|
||||
These functions assume that the concrete types behind the void* are
|
||||
- Windows: HWND
|
||||
- MacOS: NSView*
|
||||
- iOS: UIView*
|
||||
- Android: GlobalRef that points to an android.view.View
|
||||
*/
|
||||
static void* getNativeChildForComponent (Component& component);
|
||||
/** @internal */
|
||||
static void setNativeChildForComponent (Component& component, void* nativeChild);
|
||||
/** @internal */
|
||||
static Component* getComponentForNativeChild (void* nativeChild);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue