diff --git a/modules/juce_gui_basics/accessibility/interfaces/juce_AccessibilityCellInterface.h b/modules/juce_gui_basics/accessibility/interfaces/juce_AccessibilityCellInterface.h index 049c39722e..de901feeff 100644 --- a/modules/juce_gui_basics/accessibility/interfaces/juce_AccessibilityCellInterface.h +++ b/modules/juce_gui_basics/accessibility/interfaces/juce_AccessibilityCellInterface.h @@ -56,6 +56,9 @@ public: /** Returns the AccessibilityHandler of the table which contains the cell. */ virtual const AccessibilityHandler* getTableHandler() const = 0; + + /** Returns a list of the accessibility elements that are disclosed by this element, if any. */ + virtual std::vector getDisclosedRows() const { return {}; } }; } // namespace juce diff --git a/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm b/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm index b7e1ee6d9f..6c136dd043 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm +++ b/modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm @@ -528,6 +528,33 @@ private: return 0; }); + addMethod (@selector (accessibilityDisclosedRows), [] (id self, SEL) -> id + { + if (auto* handler = getHandler (self)) + { + if (auto* cellInterface = handler->getCellInterface()) + { + const auto rows = cellInterface->getDisclosedRows(); + auto* result = [NSMutableArray arrayWithCapacity: rows.size()]; + + for (const auto& row : rows) + { + if (row != nullptr) + [result addObject: static_cast (row->getNativeImplementation())]; + else + [result addObject: [NSAccessibilityElement accessibilityElementWithRole: NSAccessibilityRowRole + frame: NSZeroRect + label: @"Offscreen Row" + parent: self]]; + } + + return result; + } + } + + return nil; + }); + addMethod (@selector (isAccessibilityExpanded), [] (id self, SEL) -> BOOL { if (auto* handler = getHandler (self)) diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index 2940845c13..991610c1e5 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -161,6 +161,34 @@ private: return getItemDepth (&itemComponent.getRepresentedItem()); } + std::vector getDisclosedRows() const override + { + const auto& representedItem = itemComponent.getRepresentedItem(); + const auto* tree = representedItem.getOwnerView(); + + if (tree == nullptr) + return {}; + + const auto numSubItems = representedItem.isOpen() ? representedItem.getNumSubItems() : 0; + + std::vector result; + result.reserve ((size_t) numSubItems); + + for (auto i = 0; i < numSubItems; ++i) + { + result.push_back ([&]() -> const AccessibilityHandler* + { + if (auto* subItem = representedItem.getSubItem (i)) + if (auto* component = tree->getItemComponent (subItem)) + return component->getAccessibilityHandler(); + + return nullptr; + }()); + } + + return result; + } + const AccessibilityHandler* getTableHandler() const override { if (auto* tree = itemComponent.getRepresentedItem().getOwnerView())