Browse Source

iOS/macOS Accessibility: Tidy up shared value getter

v6.1.6
ed 4 years ago
parent
commit
a7915ec47e
3 changed files with 37 additions and 24 deletions
  1. +13
    -0
      modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm
  2. +13
    -0
      modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm
  3. +11
    -24
      modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm

+ 13
- 0
modules/juce_gui_basics/native/accessibility/juce_ios_Accessibility.mm View File

@@ -341,6 +341,19 @@ private:
return traits | sendSuperclassMessage<UIAccessibilityTraits> (self, @selector (accessibilityTraits));
}
static NSString* getAccessibilityValue (id self, SEL)
{
if (auto* handler = getHandler (self))
{
if (handler->getCurrentState().isCheckable())
return handler->getCurrentState().isChecked() ? @"1" : @"0";
return (NSString*) getAccessibilityValueFromInterfaces (*handler);
}
return nil;
}
static void onFocusGain (id self, SEL)
{
if (auto* handler = getHandler (self))


+ 13
- 0
modules/juce_gui_basics/native/accessibility/juce_mac_Accessibility.mm View File

@@ -283,6 +283,19 @@ private:
return nil;
}
static id getAccessibilityValue (id self, SEL)
{
if (auto* handler = getHandler (self))
{
if (handler->getCurrentState().isCheckable())
return handler->getCurrentState().isChecked() ? @(1) : @(0);
return getAccessibilityValueFromInterfaces (*handler);
}
return nil;
}
static NSArray* getAccessibilitySelectedChildren (id self, SEL)
{
return getSelectedChildren ([self accessibilityChildren]);


+ 11
- 24
modules/juce_gui_basics/native/accessibility/juce_mac_AccessibilitySharedCode.mm View File

@@ -78,6 +78,17 @@ protected:
&& ! handler.getTextInterface()->isReadOnly();
}
static id getAccessibilityValueFromInterfaces (const AccessibilityHandler& handler)
{
if (auto* textInterface = handler.getTextInterface())
return juceStringToNS (textInterface->getText ({ 0, textInterface->getTotalNumCharacters() }));
if (auto* valueInterface = handler.getValueInterface())
return juceStringToNS (valueInterface->getCurrentValueAsString());
return nil;
}
//==============================================================================
static BOOL getIsAccessibilityElement (id self, SEL)
{
@@ -88,30 +99,6 @@ protected:
return NO;
}
static id getAccessibilityValue (id self, SEL)
{
if (auto* handler = getHandler (self))
{
if (auto* textInterface = handler->getTextInterface())
return juceStringToNS (textInterface->getText ({ 0, textInterface->getTotalNumCharacters() }));
if (handler->getCurrentState().isCheckable())
{
return handler->getCurrentState().isChecked()
#if JUCE_IOS
? @"1" : @"0";
#else
? @(1) : @(0);
#endif
}
if (auto* valueInterface = handler->getValueInterface())
return juceStringToNS (valueInterface->getCurrentValueAsString());
}
return nil;
}
static void setAccessibilityValue (id self, SEL, NSString* value)
{
if (auto* handler = getHandler (self))


Loading…
Cancel
Save