diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2014-10-15 13:58:34 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2014-10-27 14:53:16 +0100 |
commit | 8f6436f125faae91eb472ddddbbae06dba5da671 (patch) | |
tree | cd99bd534e9e01ebddda584eb24a8bae3b195895 /src/quick/accessible | |
parent | 32af8055985c1f978574eec62512638f472e8290 (diff) |
Move action handlers to the Accessible attached object
With this change, instead of writing:
function accessiblePressAction() { submit() }
You should write:
Accessible.onPressAction: { submit() }
For the moment, only 4 actions are added:
press, toggle, increase and decrease.
The old style action handlers are deprecated, and removed from the
documentation. New style action handlers will be preferred in case an
item declares both styles.
Change-Id: I11919e631d8476d55540f94252757b911c44ade4
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Diffstat (limited to 'src/quick/accessible')
-rw-r--r-- | src/quick/accessible/qaccessiblequickitem.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp index 3234d3d85f..e13224f6fb 100644 --- a/src/quick/accessible/qaccessiblequickitem.cpp +++ b/src/quick/accessible/qaccessiblequickitem.cpp @@ -39,7 +39,6 @@ #include "QtQuick/private/qquicktext_p.h" #include "QtQuick/private/qquickaccessibleattached_p.h" #include "QtQuick/qquicktextdocument.h" - QT_BEGIN_NAMESPACE #ifndef QT_NO_ACCESSIBILITY @@ -217,16 +216,24 @@ QStringList QAccessibleQuickItem::actionNames() const QStringList actions = QQmlAccessible::actionNames(); if (state().focusable) actions.append(QAccessibleActionInterface::setFocusAction()); + + // ### The following can lead to duplicate action names. We'll fix that when we kill QQmlAccessible + if (QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item())) + attached->availableActions(&actions); return actions; } void QAccessibleQuickItem::doAction(const QString &actionName) { + bool accepted = false; if (actionName == QAccessibleActionInterface::setFocusAction()) { item()->forceActiveFocus(); - } else { - QQmlAccessible::doAction(actionName); + accepted = true; } + if (QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item())) + accepted = attached->doAction(actionName); + if (!accepted) + QQmlAccessible::doAction(actionName); } QStringList QAccessibleQuickItem::keyBindingsForAction(const QString &actionName) const |