return d->activeFocusItem;
}
+QObject *QQuickCanvas::focusObject() const
+{
+ Q_D(const QQuickCanvas);
+
+ if (d->activeFocusItem)
+ return d->activeFocusItem;
+ return const_cast<QQuickCanvas*>(this);
+}
+
+
/*!
Returns the item which currently has the mouse grab.
*/
QQuickItem *rootItem() const;
QQuickItem *activeFocusItem() const;
+ QObject *focusObject() const;
QQuickItem *mouseGrabberItem() const;
void animationsWhileHidden();
+ void focusObject();
+
private:
QTouchDevice *touchDevice;
};
}
+void tst_qquickcanvas::focusObject()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.loadUrl(testFileUrl("focus.qml"));
+ QObject *created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas *canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+
+ QQuickItem *item1 = canvas->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+ item1->setFocus(true);
+ QCOMPARE(item1, canvas->focusObject());
+
+ QQuickItem *item2 = canvas->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ item2->setFocus(true);
+ QCOMPARE(item2, canvas->focusObject());
+
+ delete canvas;
+}
+
QTEST_MAIN(tst_qquickcanvas)
#include "tst_qquickcanvas.moc"