| @@ -524,14 +524,34 @@ public: | |||
| explicit LabelAccessibilityHandler (Label& labelToWrap) | |||
| : AccessibilityHandler (labelToWrap, | |||
| AccessibilityRole::staticText, | |||
| getAccessibilityActions (labelToWrap)), | |||
| getAccessibilityActions (labelToWrap), | |||
| { std::make_unique<LabelValueInterface> (labelToWrap) }), | |||
| label (labelToWrap) | |||
| { | |||
| } | |||
| String getTitle() const override { return label.getText(); } | |||
| String getTitle() const override | |||
| { | |||
| return label.getText(); | |||
| } | |||
| private: | |||
| class LabelValueInterface : public AccessibilityTextValueInterface | |||
| { | |||
| public: | |||
| explicit LabelValueInterface (Label& labelToWrap) | |||
| : label (labelToWrap) | |||
| { | |||
| } | |||
| bool isReadOnly() const override { return true; } | |||
| String getCurrentValueAsString() const override { return label.getText(); } | |||
| void setValueAsString (const String&) override {} | |||
| private: | |||
| Label& label; | |||
| }; | |||
| static AccessibilityActions getAccessibilityActions (Label& label) | |||
| { | |||
| if (label.isEditable()) | |||
| @@ -2697,17 +2697,27 @@ public: | |||
| : AccessibilityHandler (textEditorToWrap, | |||
| textEditorToWrap.isReadOnly() ? AccessibilityRole::staticText : AccessibilityRole::editableText, | |||
| {}, | |||
| { textEditorToWrap.isReadOnly() ? nullptr : std::make_unique<TextEditorTextInterface> (textEditorToWrap) }), | |||
| textEditor (textEditorToWrap) | |||
| makeInterfaces (textEditorToWrap)) | |||
| { | |||
| } | |||
| String getTitle() const override | |||
| private: | |||
| class TextEditorValueInterface : public AccessibilityTextValueInterface | |||
| { | |||
| return textEditor.isReadOnly() ? textEditor.getText() : textEditor.getTitle(); | |||
| } | |||
| public: | |||
| explicit TextEditorValueInterface (TextEditor& textEditorToWrap) | |||
| : textEditor (textEditorToWrap) | |||
| { | |||
| } | |||
| bool isReadOnly() const override { return true; } | |||
| String getCurrentValueAsString() const override { return textEditor.getText(); } | |||
| void setValueAsString (const String&) override {} | |||
| private: | |||
| TextEditor& textEditor; | |||
| }; | |||
| private: | |||
| class TextEditorTextInterface : public AccessibilityTextInterface | |||
| { | |||
| public: | |||
| @@ -2759,7 +2769,13 @@ private: | |||
| TextEditor& textEditor; | |||
| }; | |||
| TextEditor& textEditor; | |||
| static AccessibilityHandler::Interfaces makeInterfaces (TextEditor& textEditor) | |||
| { | |||
| if (textEditor.isReadOnly()) | |||
| return { std::make_unique<TextEditorValueInterface> (textEditor) }; | |||
| return { std::make_unique<TextEditorTextInterface> (textEditor) }; | |||
| } | |||
| //============================================================================== | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextEditorAccessibilityHandler) | |||
| @@ -35,19 +35,27 @@ public: | |||
| codeEditorComponentToWrap.isReadOnly() ? AccessibilityRole::staticText | |||
| : AccessibilityRole::editableText, | |||
| {}, | |||
| { codeEditorComponentToWrap.isReadOnly() ? nullptr | |||
| : std::make_unique<CodeEditorComponentTextInterface> (codeEditorComponentToWrap) }), | |||
| codeEditorComponent (codeEditorComponentToWrap) | |||
| makeInterfaces (codeEditorComponentToWrap)) | |||
| { | |||
| } | |||
| String getTitle() const override | |||
| private: | |||
| class CodeEditorComponentValueInterface : public AccessibilityTextValueInterface | |||
| { | |||
| return codeEditorComponent.isReadOnly() ? codeEditorComponent.document.getAllContent() | |||
| : codeEditorComponent.getTitle(); | |||
| } | |||
| public: | |||
| explicit CodeEditorComponentValueInterface (CodeEditorComponent& codeEditorComponentToWrap) | |||
| : codeEditorComponent (codeEditorComponentToWrap) | |||
| { | |||
| } | |||
| bool isReadOnly() const override { return true; } | |||
| String getCurrentValueAsString() const override { return codeEditorComponent.document.getAllContent(); } | |||
| void setValueAsString (const String&) override {} | |||
| private: | |||
| CodeEditorComponent& codeEditorComponent; | |||
| }; | |||
| private: | |||
| class CodeEditorComponentTextInterface : public AccessibilityTextInterface | |||
| { | |||
| public: | |||
| @@ -144,7 +152,13 @@ private: | |||
| CodeEditorComponent& codeEditorComponent; | |||
| }; | |||
| CodeEditorComponent& codeEditorComponent; | |||
| static AccessibilityHandler::Interfaces makeInterfaces (CodeEditorComponent& codeEditorComponent) | |||
| { | |||
| if (codeEditorComponent.isReadOnly()) | |||
| return { std::make_unique<CodeEditorComponentValueInterface> (codeEditorComponent) }; | |||
| return { std::make_unique<CodeEditorComponentTextInterface> (codeEditorComponent) }; | |||
| } | |||
| //============================================================================== | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CodeEditorAccessibilityHandler) | |||