mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-15 00:24:19 +00:00
Accessibility: Send AccessibilityEvent::valueChanged when ComboBox selection is changed
This commit is contained in:
parent
0b844b7d88
commit
e6360ca4cf
1 changed files with 24 additions and 1 deletions
|
|
@ -622,6 +622,9 @@ void ComboBox::handleAsyncUpdate()
|
|||
|
||||
if (onChange != nullptr)
|
||||
onChange();
|
||||
|
||||
if (auto* handler = getAccessibilityHandler())
|
||||
handler->notifyAccessibilityEvent (AccessibilityEvent::valueChanged);
|
||||
}
|
||||
|
||||
void ComboBox::sendChange (const NotificationType notification)
|
||||
|
|
@ -646,7 +649,8 @@ public:
|
|||
explicit ComboBoxAccessibilityHandler (ComboBox& comboBoxToWrap)
|
||||
: AccessibilityHandler (comboBoxToWrap,
|
||||
AccessibilityRole::comboBox,
|
||||
getAccessibilityActions (comboBoxToWrap)),
|
||||
getAccessibilityActions (comboBoxToWrap),
|
||||
{ std::make_unique<ComboBoxValueInterface> (comboBoxToWrap) }),
|
||||
comboBox (comboBoxToWrap)
|
||||
{
|
||||
}
|
||||
|
|
@ -662,6 +666,25 @@ public:
|
|||
String getHelp() const override { return comboBox.getTooltip(); }
|
||||
|
||||
private:
|
||||
class ComboBoxValueInterface : public AccessibilityTextValueInterface
|
||||
{
|
||||
public:
|
||||
explicit ComboBoxValueInterface (ComboBox& comboBoxToWrap)
|
||||
: comboBox (comboBoxToWrap)
|
||||
{
|
||||
}
|
||||
|
||||
bool isReadOnly() const override { return true; }
|
||||
String getCurrentValueAsString() const override { return comboBox.getText(); }
|
||||
void setValueAsString (const String&) override {}
|
||||
|
||||
private:
|
||||
ComboBox& comboBox;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBoxValueInterface)
|
||||
};
|
||||
|
||||
static AccessibilityActions getAccessibilityActions (ComboBox& comboBox)
|
||||
{
|
||||
return AccessibilityActions().addAction (AccessibilityActionType::press, [&comboBox] { comboBox.showPopup(); })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue