'Return' keyboard shortcut for FlatButton control not working

• Feb 28, 2025 - 02:39

Hi there — my plugin shows an ApplicationWindow once it's finished processing. This window has a FlatButton in it as in the code segment below which uses Keys.onReturnPressed to click the button. But the 'return' key is not doing anything — perhaps this element has not been implemented by MuseScore, or I'm misunderstanding how to do this. Anyone got any clues?

ApplicationWindow {
    id: dialog
    title: "CHECK COMPLETED"
    property var msg: ""
    visible: false
    width: 500
    height: 400
    Keys.enabled: true

    Item {
        anchors.fill: parent
        focus: true
        Keys.onReturnPressed: dialog.close()
        Keys.onEnterPressed: dialog.close()

        Text {
            id: theText
            width: parent.width-40
            x: 20
            y: 20

            text: "MN CHECK LAYOUT AND INSTRUMENTATION"
            font.bold: true
            font.pointSize: 18
        }
        Rectangle {
            x:20
            width: parent.width-40
            y:45
            height: 1
            color: "black"
        }

        ScrollView {
            id: view
            x: 20
            y: 60
            height: parent.height-100
            width: parent.width-40
            leftInset: 0
            leftPadding: 0

            ScrollBar.vertical.policy: ScrollBar.AsNeeded
            TextArea {
                text: dialog.msg
                wrapMode: TextEdit.Wrap
                leftInset: 0
                leftPadding: 0
                readOnly: true
            }
        }
        FlatButton {            
            accentButton: true
            text: "Ok"
            focus: true
            anchors {
                horizontalCenter: parent.horizontalCenter
                bottom: parent.bottom
                margins: 10
            }
            onClicked: dialog.close()
            Keys.onReturnPressed: {
                clicked()
                event.accepted = true
            }
        }
    }
}

Do you still have an unanswered question? Please log in first to post your question.