2018-09-23 19:06:26 -07:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
|
|
|
|
MenuItem {
|
2019-02-09 19:59:01 -08:00
|
|
|
// Qt 5.10 has a menu property, but we need to support 5.9
|
|
|
|
// so we must make our own.
|
|
|
|
property Menu parentMenu
|
|
|
|
|
2018-09-30 13:41:32 -07:00
|
|
|
// Ensure focus can't be given to an invisible item
|
|
|
|
enabled: visible
|
|
|
|
height: visible ? implicitHeight : 0
|
2019-02-09 19:21:43 -08:00
|
|
|
focusPolicy: visible ? Qt.TabFocus : Qt.NoFocus
|
2018-09-30 13:41:32 -07:00
|
|
|
|
2019-03-31 19:40:30 -07:00
|
|
|
onTriggered: {
|
|
|
|
// We must close the context menu first or
|
|
|
|
// it can steal focus from any dialogs that
|
|
|
|
// onTriggered may spawn.
|
|
|
|
parentMenu.close()
|
|
|
|
}
|
|
|
|
|
2018-09-23 19:06:26 -07:00
|
|
|
Keys.onReturnPressed: {
|
|
|
|
triggered()
|
|
|
|
}
|
2019-02-09 19:59:01 -08:00
|
|
|
|
2021-02-27 23:01:22 +00:00
|
|
|
Keys.onEnterPressed: {
|
|
|
|
triggered()
|
|
|
|
}
|
|
|
|
|
2019-02-09 19:59:01 -08:00
|
|
|
Keys.onEscapePressed: {
|
|
|
|
parentMenu.close()
|
|
|
|
}
|
2018-09-23 19:06:26 -07:00
|
|
|
}
|