#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
+#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <qaccessibleplugin.h>
if (classname == QLatin1String("QQuickView")) {
return new QAccessibleQuickView(qobject_cast<QQuickView *>(object)); // FIXME
} else if (classname == QLatin1String("QQuickItem")) {
- QQuickItem * item = qobject_cast<QQuickItem *>(object);
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
Q_ASSERT(item);
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ if (!itemPrivate->isAccessible)
+ return 0;
QVariant v = QQuickAccessibleAttached::property(item, "role");
bool ok;
}
QScopedPointer<QAccessibleInterface> accessibleInterface(QAccessible::queryAccessibleInterface(item));
- if (accessibleInterface && accessibleInterface->childCount() == 0) {
+ // this item has no Accessible attached property
+ if (!accessibleInterface)
+ return 0;
+
+ if (accessibleInterface->childCount() == 0) {
return (itemScreenRect(item).contains(x, y)) ? item : 0;
}
if (root) {
if (QQuickItem *item = childAt_helper(root, x, y))
return QAccessible::queryAccessibleInterface(item);
+ return QAccessible::queryAccessibleInterface(root);
}
return 0;
}
if (item->d_func()->isAccessible)
break; // already set - grandparents should have the flag set as well.
- if (item->canvas() && item->canvas()->rootItem() == item)
- break; // don't add a listener to the canvas root item
-
item->d_func()->isAccessible = true;
item = item->d_func()->parentItem;
}
QAI rootItem = QAI(canvasIface->child(0));
QRect rootRect = rootItem->rect();
- // hit the root item
- QAI rootItemIface(canvasIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
- QVERIFY(rootItemIface);
- QCOMPARE(rootRect, rootItemIface->rect());
+ // check the root item from app
+ QAI appIface = QAI(QAccessible::queryAccessibleInterface(qApp));
+ QVERIFY(appIface);
+ QAI itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
+ QVERIFY(itemHit);
+ QCOMPARE(rootRect, itemHit->rect());
// hit rect1
QAI rect1(rootItem->child(0));
QRect rect1Rect = rect1->rect();
- rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QAI rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
QVERIFY(rootItemIface);
QCOMPARE(rect1Rect, rootItemIface->rect());
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));