2018-09-24 02:06:26 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
|
|
|
|
MenuItem {
|
2019-02-10 03:59:01 +00: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 20:41:32 +00:00
|
|
|
// Ensure focus can't be given to an invisible item
|
|
|
|
enabled: visible
|
|
|
|
height: visible ? implicitHeight : 0
|
2019-02-10 03:21:43 +00:00
|
|
|
focusPolicy: visible ? Qt.TabFocus : Qt.NoFocus
|
2018-09-30 20:41:32 +00:00
|
|
|
|
2019-04-01 02:40:30 +00: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-24 02:06:26 +00:00
|
|
|
Keys.onReturnPressed: {
|
|
|
|
triggered()
|
|
|
|
}
|
2019-02-10 03:59:01 +00:00
|
|
|
|
|
|
|
Keys.onEscapePressed: {
|
|
|
|
parentMenu.close()
|
|
|
|
}
|
2018-09-24 02:06:26 +00:00
|
|
|
}
|