, persistentSceneGraph(true)
, lastWheelEventAccepted(false)
, componentCompleted(true)
+ , lastFocusReason(Qt::OtherFocusReason)
, renderTarget(0)
, renderTargetId(0)
, incubationController(0)
QQuickItem *currentActiveFocusItem = activeFocusItem;
QQuickItem *newActiveFocusItem = 0;
+ lastFocusReason = reason;
+
QVarLengthArray<QQuickItem *, 20> changed;
// Does this change the active focus?
QQuickItem *oldActiveFocusItem = 0;
QQuickItem *newActiveFocusItem = 0;
+ lastFocusReason = reason;
+
QVarLengthArray<QQuickItem *, 20> changed;
Q_ASSERT(item == contentItem || item == scopePrivate->subFocusItem);
void animationsWhileHidden();
void focusObject();
+ void focusReason();
void ignoreUnhandledMouseEvents();
QCOMPARE(focusObjectSpy.count(), 3);
}
+void tst_qquickwindow::focusReason()
+{
+ QQuickWindow *window = new QQuickWindow;
+ QScopedPointer<QQuickWindow> cleanup(window);
+ window->resize(200, 200);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickItem *firstItem = new QQuickItem;
+ firstItem->setSize(QSizeF(100, 100));
+ firstItem->setParentItem(window->contentItem());
+
+ QQuickItem *secondItem = new QQuickItem;
+ secondItem->setSize(QSizeF(100, 100));
+ secondItem->setParentItem(window->contentItem());
+
+ firstItem->forceActiveFocus(Qt::OtherFocusReason);
+ QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::OtherFocusReason);
+
+ secondItem->forceActiveFocus(Qt::TabFocusReason);
+ QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::TabFocusReason);
+
+ firstItem->forceActiveFocus(Qt::BacktabFocusReason);
+ QCOMPARE(QQuickWindowPrivate::get(window)->lastFocusReason, Qt::BacktabFocusReason);
+
+}
+
void tst_qquickwindow::ignoreUnhandledMouseEvents()
{
QQuickWindow *window = new QQuickWindow;