WIP to setup the keys event
This commit is contained in:
@@ -19,7 +19,14 @@ Application {
|
||||
|
||||
color: "#000B25"
|
||||
|
||||
focus: true
|
||||
|
||||
View.Login {}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Setup the login view to be focus on start
|
||||
columnLogin.updateSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user