Pascaldietz (Talk | contribs) (created ModalContextMenu API Snapshot page) |
Pascaldietz (Talk | contribs) (removed private properties) |
||
| Line 18: | Line 18: | ||
:: 2: arrow tip will point to up // this should be set for tool bar menus | :: 2: arrow tip will point to up // this should be set for tool bar menus | ||
:: 3: arrow tip will point to down | :: 3: arrow tip will point to down | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
=Signals= | =Signals= | ||
Contents |
This qml provides an empty context menu. You can setPosition() where the menu should show up. On show() it will appear pointing to the given position and display the content set via the content property.
ModalcontextMenu {
id: contextmenu
content: ActionMenu {
id: actionMenu
model: [ "First choice", "Second choice" ]
payload: [ 1, 2 ]
onTriggered: {
// data can be acessed via payload[index]
contextmenu.hide() // hide if desired
}
}
}
TopItem { id: topItem } // this item is needed to compute the correct position of the context menu on screen
function someFunction() {
contextmenu.setPosition(
windowMenuButton.x + windowMenuButton.width / 2,
mapToItem( window, window.width / 2, windowMenuButton.y + windowMenuButton.height ).y
)
contextmenu.show()
}