fix checkbox switch (#1777)

This commit is contained in:
Cyril Anisimov
2025-08-10 05:13:58 +02:00
committed by GitHub
parent 9fdcf5ab13
commit e9d4fd8482

View File

@@ -173,15 +173,17 @@ CheckBox {
enabled: false
}
Keys.onEnterPressed: event => handleSwitch(event)
Keys.onReturnPressed: event => handleSwitch(event)
Keys.onSpacePressed: event => handleSwitch(event)
Keys.onEnterPressed: {
root.checked = !root.checked
function handleSwitch(event) {
if (!event.isAutoRepeat) {
root.checked = !root.checked
root.checkedChanged()
}
event.accepted = true
}
Keys.onReturnPressed: {
root.checked = !root.checked
}
}