Hello, The Keyboard Focus in QML overview is broken in the 4.7.0 and 4.7.1 release. I've fixed the incorrect document (not yet passed the CI) and I will add information about Item::forceActiveFocus() in there as well.
Cheers, Jerome Pasion ________________________________________ From: [email protected] [[email protected]] On Behalf Of ext Girish Ramakrishnan [[email protected]] Sent: Thursday, December 16, 2010 5:03 PM To: [email protected] Subject: [Qt-qml] FocusScope gives focus to the last item with focus: true Hi, Per the docs (http://doc.qt.nokia.com/4.7-snapshot/qdeclarativefocus.html#qmlfocus), "Within each focus scope one element may have Item::focus set to true. If more than one Item has the Item::focus property set, the first is selected and the others are unset, just like when there are no focus scopes.". In the code below, rect2 gets focus which appears to contradict what the docs say. Also, the 'non-working' example in the documentation, works just fine (i.e the MyWidget example that shows the expanded QML code on the right without using FocusScope). And this appears to be because the last 'focus' item got focus. I am using 4.7.1. Girish FocusScope { id: rect width: 100 height: 100 focus: true Rectangle { id: rect1 focus: true anchors.fill: parent Keys.onPressed: { console.log('a key was pressed in rect1') } } Rectangle { id: rect2 focus: true anchors.fill: parent Keys.onPressed: { console.log('a key was pressed in rect2') } } } _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
