WIP to setup the keys event

This commit is contained in:
Aurelien Vaillant
2024-08-13 18:15:38 +02:00
parent 1b28d953c2
commit 586d9e854e
2 changed files with 30 additions and 0 deletions
+7
View File
@@ -19,7 +19,14 @@ Application {
color: "#000B25"
focus: true
View.Login {}
}
Component.onCompleted: {
// Setup the login view to be focus on start
columnLogin.updateSelection();
}
}
}
+23
View File
@@ -8,12 +8,21 @@ Column {
{label: "Password", type: "password"}
]
property int currentIndex: 0
id: columnLogin
//anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 20
spacing: 15
width: parent.width * 0.8
function updateSelection() {
for (let i = 0; i < repeater.count; i++) {
repeater.itemAt(i).color = i === columnLogin.currentIndex ? "lightblue" : "transparent";
}
}
// Repeater pour générer les champs basés sur la liste des labels et types
Repeater {
@@ -48,5 +57,19 @@ Column {
}
}
}
Keys.onPressed: {
if (event.key === Qt.Key_Up) {
if (currentIndex > 0) {
currentIndex--;
updateSelection();
}
} else if (event.key == Qt.Key_Down) {
if (currentIndex < repeater.children.length - 1) {
currentIndex++;
updateSelection()
}
}
}
}
}