mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
iOS/macOS Accessibility: Tidy up shared value getter
This commit is contained in:
parent
2abf68d866
commit
a7915ec47e
3 changed files with 37 additions and 24 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue