[Qt-qml] Components, loaders, and focus scope

mathias.malmqvist at nokia.com mathias.malmqvist at nokia.com
Thu Dec 16 15:40:56 CET 2010


Oh by the way, if I add "focus: true" to each of the Loaders as suggested here
http://doc.qt.nokia.com/4.7/qml-loader.html#focus-and-key-events

then I can click on the last of the three to give it focus, but nothing happens when I click on one of the other two.


Cheers
Mathias
________________________________________
From: qt-qml-bounces+mathias.malmqvist=nokia.com at qt.nokia.com [qt-qml-bounces+mathias.malmqvist=nokia.com at qt.nokia.com] On Behalf Of Malmqvist Mathias (Nokia-MS/London)
Sent: Thursday, December 16, 2010 2:13 PM
To: qt-qml at qt.nokia.com
Subject: [Qt-qml] Components, loaders, and focus scope

Hi,

Can anyone suggest why the code below doesn't work?

Clicking on the text input components one at a time should move focus between them, but nothing happens.
I've read the documentation here http://doc.qt.nokia.com/4.7/qdeclarativefocus.html
but no change I've made to the code below has made it work.

However if I comment out the two last lines in the the textInputComponent (activeFocusOnPress and MouseArea) then it does work.
Unfortunately this is not an option in my case. Is this due to a bug?

Any suggestions appreciated!
Thanks!


import QtQuick 1.0
Rectangle {
    width: 800
    height: 480

    Loader {
        x: 100; y: 100
        sourceComponent: textInputComponent
    }

    Loader {
        x: 100; y: 200
        sourceComponent: textInputComponent
    }

    Loader {
        x: 100; y: 300
        sourceComponent: textInputComponent
    }

    Component {
        id: textInputComponent
        TextInput {
            width: 200
            height: 20
            Rectangle { color: parent.activeFocus ? "green" : "red"; anchors.fill: parent; z: -1 }

            activeFocusOnPress: false
            MouseArea { anchors.fill: parent; onClicked: parent.focus = true }
        }
    }
}



Cheers
Mathias

_______________________________________________
Qt-qml mailing list
Qt-qml at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml


More information about the Qt-qml mailing list