I want to use a press-and-hold behaviour to switch states of a gui Item.
I use a FocusScope
(below) to recieve keyboard events.
FocusScope{
id:pageFocus
property var pedalKey//a key id
Keys.enabled: true
Keys.onPressed: {
if(event.key===pedalKey && !event.isAutoRepeat)
{
state="a"
}
}
Keys.onReleased: {
if(event.key===pedalKey && !event.isAutoRepeat)
{
state="b"
}
}
}
It works, but when FocusScope
loses the focus.
The most terrible thing is that I don't know which Item
got the focus.
Is there any way to enable the Item
to receive keyboard events without focus?