29AccessibilityHandler* AccessibilityHandler::currentlyFocusedHandler =
nullptr;
40 void* getNativeChild (
Component& component)
const
42 if (
auto it = nativeChildForComponent.find (&component);
43 it != nativeChildForComponent.end())
54 it != componentForNativeChild.end())
64 clearComponent (component);
76 void clearComponent (
Component& component)
81 nativeChildForComponent.erase (&component);
93 typeIndex (
typeid (component)),
97 nativeImpl (createNativeImpl (*
this))
104 detail::AccessibilityHelpers::notifyAccessibilityEvent (*
this, detail::AccessibilityHelpers::Event::elementDestroyed);
116 return hasFocus (
false) ? state.withFocused() : state;
124static bool isComponentVisibleWithinWindow (
const Component& comp)
126 if (
auto* peer = comp.
getPeer())
127 return ! peer->getAreaCoveredBy (comp).getIntersection (peer->getComponent().getLocalBounds()).isEmpty();
132static bool isComponentVisibleWithinParent (Component* comp)
134 if (
auto* parent = comp->getParentComponent())
136 if (comp->getBoundsInParent().getIntersection (parent->getLocalBounds()).isEmpty())
139 return isComponentVisibleWithinParent (parent);
148 || (isComponentVisibleWithinParent (&component) && isComponentVisibleWithinWindow (component));
159 return interfaces.value.get();
164 return interfaces.table.get();
169 return interfaces.cell.get();
174 return interfaces.text.get();
191static AccessibilityHandler* getUnignoredAncestor (AccessibilityHandler* handler)
193 while (handler !=
nullptr
194 && (handler->isIgnored() || ! handler->isVisibleWithinParent())
195 && handler->getParent() !=
nullptr)
208 [] (
const AccessibilityHandler* handler) { return ! handler->isIgnored() && handler->isVisibleWithinParent(); });
214 if (
auto*
unignored = findFirstUnignoredChild (handler->getChildren()))
221static AccessibilityHandler* getFirstUnignoredDescendant (AccessibilityHandler* handler)
223 if (handler !=
nullptr && (handler->isIgnored() || ! handler->isVisibleWithinParent()))
224 return findFirstUnignoredChild (handler->getChildren());
232 return getUnignoredAncestor (findEnclosingHandler (focusContainer));
250 if (! handler->getCurrentState().isFocusable() || !
isParentOf (handler))
253 if (
auto*
unignored = getFirstUnignoredDescendant (handler))
289 if (
auto* handler = getUnignoredAncestor (findEnclosingHandler (comp)))
299 return hasFocus (
true) ? getUnignoredAncestor (currentlyFocusedHandler)
305 return currentlyFocusedHandler !=
nullptr
306 && (currentlyFocusedHandler ==
this
313 grabFocusInternal (
true);
319 giveAwayFocusInternal();
322void AccessibilityHandler::grabFocusInternal (
bool canTryParent)
337 if (
auto* handler = getUnignoredAncestor (findEnclosingHandler (
defaultComp)))
341 handler->grabFocusInternal (
false);
350 parent->grabFocusInternal (
true);
353void AccessibilityHandler::giveAwayFocusInternal()
const
355 currentlyFocusedHandler =
nullptr;
356 detail::AccessibilityHelpers::notifyAccessibilityEvent (*
this, detail::AccessibilityHelpers::Event::focusChanged);
359void AccessibilityHandler::takeFocus()
361 currentlyFocusedHandler =
this;
362 detail::AccessibilityHelpers::notifyAccessibilityEvent (*
this, detail::AccessibilityHelpers::Event::focusChanged);
374 #if JUCE_NATIVE_ACCESSIBILITY_INCLUDED
375 return std::make_unique<AccessibilityNativeImpl> (handler);
382void* AccessibilityHandler::getNativeChildForComponent (Component& component)
384 return NativeChildHandler::getInstance().getNativeChild (component);
387Component* AccessibilityHandler::getComponentForNativeChild (
void*
nativeChild)
389 return NativeChildHandler::getInstance().getComponent (
nativeChild);
392void AccessibilityHandler::setNativeChildForComponent (Component& component,
void*
nativeChild)
394 NativeChildHandler::getInstance().setNativeChild (component,
nativeChild);
397#if ! JUCE_NATIVE_ACCESSIBILITY_INCLUDED
400 AccessibilityNativeHandle* AccessibilityHandler::getNativeImplementation()
const {
return nullptr; }
A simple wrapper for building a collection of supported accessibility actions and corresponding callb...
An abstract interface which represents a UI element that supports a cell interface.
Base class for accessible Components.
virtual AccessibleState getCurrentState() const
Returns the current state of the UI element.
virtual ~AccessibilityHandler()
Destructor.
std::vector< AccessibilityHandler * > getChildren() const
Returns the unignored children of this UI element in the accessibility hierarchy.
void grabFocus()
Tries to give focus to this UI element.
const AccessibilityActions & getActions() const noexcept
Returns the set of actions that the UI element supports and the associated callbacks.
AccessibilityCellInterface * getCellInterface() const
Returns the cell interface for this UI element, or nullptr if it is not supported.
AccessibilityHandler * getChildAt(Point< int > screenPoint)
Returns the deepest child of this UI element in the accessibility hierarchy that contains the given s...
bool isIgnored() const
Returns true if this UI element should be ignored by accessibility clients.
AccessibilityHandler * getChildFocus()
Returns the deepest UI element which currently has focus.
bool hasFocus(bool trueIfChildFocused) const
Returns true if this UI element has the focus.
void giveAwayFocus() const
If this UI element or any of its children in the accessibility hierarchy currently have focus,...
void notifyAccessibilityEvent(AccessibilityEvent event) const
Used to send a notification to any observing accessibility clients that something has changed in the ...
AccessibilityTableInterface * getTableInterface() const
Returns the table interface for this UI element, or nullptr if it is not supported.
AccessibilityHandler * getParent() const
Returns the first unignored parent of this UI element in the accessibility hierarchy,...
AccessibilityValueInterface * getValueInterface() const
Returns the value interface for this UI element, or nullptr if it is not supported.
AnnouncementPriority
A priority level that can help an accessibility client determine how to handle an announcement reques...
bool isVisibleWithinParent() const
Returns true if this UI element is visible within its parent.
AccessibilityTextInterface * getTextInterface() const
Returns the text interface for this UI element, or nullptr if it is not supported.
static void postAnnouncement(const String &announcementString, AnnouncementPriority priority)
Posts an announcement to be made to the user.
AccessibilityHandler(Component &componentToWrap, AccessibilityRole accessibilityRole, AccessibilityActions actions={}, Interfaces interfaces={})
Constructor.
bool isParentOf(const AccessibilityHandler *possibleChild) const noexcept
Checks whether a given UI element is a child of this one in the accessibility hierarchy.
An abstract interface which represents a UI element that supports a table interface.
An abstract interface which represents a UI element that supports a text interface.
An abstract interface representing the value of an accessibility element.
Represents the state of an accessible UI element.
bool isAccessibleOffscreen() const noexcept
Returns true if the UI element is accessible offscreen.
AccessibleState withFocusable() const noexcept
Sets the focusable flag and returns the new state.
bool isIgnored() const noexcept
Returns true if the UI element is ignored.
The base class for all JUCE user-interface objects.
static Component *JUCE_CALLTYPE getCurrentlyModalComponent(int index=0) noexcept
Returns one of the components that are currently modal.
bool isVisible() const noexcept
Tests whether the component is visible or not.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
void grabKeyboardFocus()
Tries to give keyboard focus to this component.
Component * findFocusContainer() const
Returns the focus container for this component.
bool isShowing() const
Tests whether this component and all its parents are visible.
bool hasKeyboardFocus(bool trueIfChildIsFocused) const
Returns true if this component currently has the keyboard focus.
bool isCurrentlyBlockedByAnotherModalComponent() const
Checks whether there's a modal component somewhere that's stopping this one from receiving messages.
AccessibilityHandler * getAccessibilityHandler()
Returns the accessibility handler for this component, or nullptr if this component is not accessible.
bool isOnDesktop() const noexcept
Returns true if this component is currently showing on the desktop.
bool isFocusContainer() const noexcept
Returns true if this component has been marked as a focus container.
virtual std::unique_ptr< ComponentTraverser > createFocusTraverser()
Creates a ComponentTraverser object to determine the logic by which focus should be passed from this ...
bool getWantsKeyboardFocus() const noexcept
Returns true if the component is interested in getting keyboard focus.
ComponentPeer * getPeer() const
Returns the heavyweight window that contains this component.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
A pair of (x, y) coordinates.
AccessibilityEvent
A list of events that can be notified to any subscribed accessibility clients.
void ignoreUnused(Types &&...) noexcept
Handy function for avoiding unused variables warning.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
AccessibilityRole
The list of available roles for an AccessibilityHandler object.
Utility struct which holds one or more accessibility interfaces.