wasm: a11y - Implement support for disabled attribute
Fixes: QTBUG-137449 Change-Id: I6aa07c7108b5ad14c12e6f24e71b8dda12fec483 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
60841478d3
commit
30c254591d
@ -454,7 +454,7 @@ void QWasmAccessibility::setHtmlElementVisibility(QAccessibleInterface *iface, b
|
||||
|
||||
container.call<void>("appendChild", element);
|
||||
|
||||
visible = visible && !iface->state().invisible && !iface->state().disabled;
|
||||
visible = visible && !iface->state().invisible;
|
||||
setProperty(element, "ariaHidden", !visible); // ariaHidden mean completely hidden; maybe some sort of soft-hidden should be used.
|
||||
}
|
||||
|
||||
@ -513,6 +513,12 @@ void QWasmAccessibility::setHtmlElementFocus(QAccessibleInterface *iface)
|
||||
element.call<void>("focus");
|
||||
}
|
||||
|
||||
void QWasmAccessibility::setHtmlElementDisabled(QAccessibleInterface *iface)
|
||||
{
|
||||
auto element = ensureHtmlElement(iface);
|
||||
setAttribute(element, "aria-disabled", iface->state().disabled);
|
||||
}
|
||||
|
||||
void QWasmAccessibility::handleStaticTextUpdate(QAccessibleEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
@ -677,6 +683,7 @@ void QWasmAccessibility::populateAccessibilityTree(QAccessibleInterface *iface)
|
||||
setHtmlElementVisibility(iface, true);
|
||||
setHtmlElementGeometry(iface);
|
||||
setHtmlElementTextName(iface);
|
||||
setHtmlElementDisabled(iface);
|
||||
handleIdentifierUpdate(iface);
|
||||
handleDescriptionChanged(iface);
|
||||
}
|
||||
@ -853,6 +860,12 @@ void QWasmAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
|
||||
// Handle some common event types. See
|
||||
// https://doc.qt.io/qt-5/qaccessible.html#Event-enum
|
||||
switch (event->type()) {
|
||||
case QAccessible::StateChanged: {
|
||||
QAccessibleStateChangeEvent *stateChangeEvent = (QAccessibleStateChangeEvent *)event;
|
||||
if (stateChangeEvent->changedStates().disabled)
|
||||
setHtmlElementDisabled(iface);
|
||||
} break;
|
||||
|
||||
case QAccessible::DescriptionChanged:
|
||||
handleDescriptionChanged(iface);
|
||||
return;
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
void setHtmlElementTextName(QAccessibleInterface *iface);
|
||||
void setHtmlElementTextNameLE(QAccessibleInterface *iface);
|
||||
void setHtmlElementFocus(QAccessibleInterface *iface);
|
||||
void setHtmlElementDisabled(QAccessibleInterface *iface);
|
||||
|
||||
void handleStaticTextUpdate(QAccessibleEvent *event);
|
||||
void handleButtonUpdate(QAccessibleEvent *event);
|
||||
|
@ -3377,8 +3377,25 @@ QAction *QWidget::addAction(const QIcon &icon, const QString &text, const QKeySe
|
||||
void QWidget::setEnabled(bool enable)
|
||||
{
|
||||
Q_D(QWidget);
|
||||
|
||||
#if QT_CONFIG(accessibility)
|
||||
const bool wasEnabled = !testAttribute(Qt::WA_ForceDisabled);
|
||||
#endif
|
||||
|
||||
setAttribute(Qt::WA_ForceDisabled, !enable);
|
||||
d->setEnabled_helper(enable);
|
||||
|
||||
#if QT_CONFIG(accessibility)
|
||||
// A widget is enabled if it's parent and itself is enabled.
|
||||
// We do not send state changed events recursively. It is up
|
||||
// to the receiver of the events to check children if required.
|
||||
if (QAccessible::isActive() && wasEnabled != enable) {
|
||||
QAccessible::State states;
|
||||
states.disabled = 1;
|
||||
QAccessibleStateChangeEvent scEvent(this, states);
|
||||
QAccessible::updateAccessibility(&scEvent);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWidgetPrivate::setEnabled_helper(bool enable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user