From 94b1c07c31ab84d30b198cb23291a48f98164827 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 6 Aug 2010 13:39:10 +1000 Subject: Top-level QML item should not have special focus handling. It's the scene itself that acts as a focus scope, not the top-level item. Task-number: QTBUG-12682 Reviewed-by: Aaron Kennedy --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 11 ++++------- .../qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 5b74129..ff05997 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -3196,8 +3196,7 @@ bool QDeclarativeItem::hasActiveFocus() const { Q_D(const QDeclarativeItem); return focusItem() == this || - (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0) || - (!parentItem() && focusItem() != 0); + (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0); } /*! @@ -3217,10 +3216,8 @@ bool QDeclarativeItem::hasActiveFocus() const } \endqml - For the purposes of this property, the top level item in the scene - is assumed to act like a focus scope, and to always have active focus - when the scene has focus. On a practical level, that means the following - QML will give active focus to \c input on startup. + For the purposes of this property, the scene as a whole is assumed to act like a focus scope. + On a practical level, that means the following QML will give active focus to \c input on startup. \qml Rectangle { @@ -3246,7 +3243,7 @@ bool QDeclarativeItem::hasFocus() const p = p->parentItem(); } - return hasActiveFocus() ? true : (!QGraphicsItem::parentItem() ? true : false); + return hasActiveFocus(); } /*! \internal */ diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index b138f61..ec8f048 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -336,7 +336,7 @@ void tst_qdeclarativefocusscope::noParentFocus() view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml")); QVERIFY(view->rootObject()); - QVERIFY(view->rootObject()->property("focus1") == true); + QVERIFY(view->rootObject()->property("focus1") == false); QVERIFY(view->rootObject()->property("focus2") == false); QVERIFY(view->rootObject()->property("focus3") == true); QVERIFY(view->rootObject()->property("focus4") == true); -- cgit v0.12