I am trying to add a keyboard shortcut to my QML but I am having a hard time getting it working without repeating logic. Below is the code,
Controls.Button {
id:sendAction
Shortcut {
sequence: "Ctrl+Return"
onActivated: parent.trigger()
}
onPressed: {call function}
}
If I repeat the calling of the function, the keyboard shortcut works but with parent.trigger()
it fails with trigger isn't a property of the button. I have tried looking up what functions can be called in a shortcut to trigger the parent but the documentation is quite light. Essentially what I need though is what to add in to onActivated
to trigger the onPressed
without repeating the function call.
Solved with the code below.
Item {
Shortcut{
id: sendShortcut
sequences: ["Ctrl+Enter", "Ctrl+Return"]
onActivated: sendAction.action.trigger()
}
}
Controls.Button {
id:sendAction
action: Controls.Action {
onTriggered{
call function
}
}
onPressed: action.trigger()
}