Seite 1 von 1

KeyNavigation will nicht

Verfasst: 29. März 2021 12:34
von Ronnic
Hallo
ich versuche gerade die Pfeiltasten zur Steurerung vom Focus zu verwenden. Ich kann zwar den Fokus durch anklicken auf ein Rectangle setzen, nicht aber durch verwenden der Pfeiltasten. Was mache ich falsch?

Code: Alles auswählen

Item
{
   id:theUe10Content
   width: 400; height: 200

    Rectangle
    {
       id: lightblue_square
       width: 50; height: 50
       color: (focus ==true)? "red" : "lightblue"

       anchors
       {
            left:parent.left
            top:parent.top
            leftMargin:35
            topMargin:35
       }

       MouseArea
       {
           anchors.fill:parent
           onClicked: parent.focus = true
       }
       KeyNavigation.right: green_square
    }

    Rectangle
    {
        id: green_square
        width: 50; height: 50
        color:focus? "red":"green"
        anchors
        {
             right:parent.right
             top:parent.top
             rightMargin:35
             topMargin:35
        }

        MouseArea
        {
            anchors.fill:parent
            onClicked: parent.focus = true
        }
        KeyNavigation.left:lightblue_square
    }
   }