Meego Wiki
Views

ModalContextMenu API Snapshot

From MeeGo wiki
Jump to: navigation, search

Contents

Description

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.

API Properties

variant content
The content the contextMenu will show, e.g. an ActionMenu.
variant title
The title of the context menu.
string[] subMenuModel
The entries the sub menu will show.
string[] subMenuPayload
The sub menus payload.
int forceFingerMode
The context menu will apear in the set finger mode. If set to -1, the default, the context menu will choose the most appropriate mode.
-1: arrow tip and menu position will be chosen automatically
0: arrow tip will point to the left
1: arrow tip will point to the right
2: arrow tip will point to up // this should be set for tool bar menus
3: arrow tip will point to down

Signals

subMenuTriggered
Emitted when one of the sub menu entries was clicked
Parameters:
  • int index, the index of the clicked entry

Functions

show
Fades the ModalContextMenu in
hide
Fades the ModalContextMenu out
setPosition
Sets the position the menu will point to. IMPORTANT: you have to map the mouse position to the topItem in the widget that got the event.
Parameters:
  • int x, the x menu position
  • int y, the y menu position

Example

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()
}
Personal tools