refactor SwitcherType

This commit is contained in:
Cyril Anisimov 2024-12-14 19:34:24 +01:00
parent 378db1a9e5
commit 3021066180

View file

@ -158,23 +158,11 @@ Switch {
enabled: false
}
Keys.onEnterPressed: {
if (!event.isAutoRepeat) {
root.checked = !root.checked
root.checkedChanged()
}
event.accepted = true
}
Keys.onEnterPressed: event => handleSwitch(event)
Keys.onReturnPressed: event => handleSwitch(event)
Keys.onSpacePressed: event => handleSwitch(event)
Keys.onReturnPressed: {
if (!event.isAutoRepeat) {
root.checked = !root.checked
root.checkedChanged()
}
event.accepted = true
}
Keys.onSpacePressed: {
function handleSwitch(event) {
if (!event.isAutoRepeat) {
root.checked = !root.checked
root.checkedChanged()