/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
QT_BEGIN_NAMESPACE
/*!
- \qmlclass Accessible QQuickAccessibleAttached
+ \qmltype Accessible
+ \instantiates QQuickAccessibleAttached
+ \brief Enables accessibility of QML items
+
\inqmlmodule QtQuick 2
- \ingroup qml-basic-interaction-elements
- \brief Attached property to enable accessibility of QML items.
+ \ingroup qtquick-visual-utility
+ \ingroup accessibility
+
+ This class is part of \l {Accessibility for Qt Quick Applications}.
Items the user interacts with or that give information to the user
need to expose their information in a semantic way.
\qml
Item {
id: myButton
+
Text {
id: label
// ...
}
+
Accessible.name: label.text
Accessible.role: Accessible.Button
+
+ function accessiblePressAction() {
+ //...
+ }
}
\endqml
+
+ Some roles have special semantics.
+ In order to implement check boxes for example a "checked" property is expected.
+
+ \table
+ \header
+ \li \b {Role}
+ \li \b {Expected property}
+ \li
+
+ \row
+ \li Button
+ \li function accessiblePressAction
+ \li Called when the button receives a press action. The implementation should visually simulate a button click and perform the button action.
+ \row
+ \li CheckBox, Radiobutton
+ \li checked
+ \li The check state of the check box. Updated on Press, Check and Uncheck actions.
+ \row
+ \li Slider, SpinBox, Dial, ScrollBar
+ \li value, minimumValue, maximumValue, stepSize
+ \li value will be updated on increase and decrase actions, in accordance with the other properties
+
+ \endtable
*/
QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent)
- : QObject(parent)
+ : QObject(parent), m_role(QAccessible::NoRole)
{
Q_ASSERT(parent);
QQuickItem *item = qobject_cast<QQuickItem*>(parent);
// Enable accessibility for items with accessible content. This also
// enables accessibility for the ancestors of souch items.
item->d_func()->setAccessibleFlagAndListener();
- QAccessible::updateAccessibility(item, 0, QAccessible::ObjectCreated);
+ QAccessibleEvent ev(item, QAccessible::ObjectCreated);
+ QAccessible::updateAccessibility(&ev);
}
QQuickAccessibleAttached::~QQuickAccessibleAttached()