plasma components ContextMenu

Marco Martin notmart at gmail.com
Sun Aug 12 10:51:19 UTC 2012


On Saturday 11 August 2012, Gregor Tätzner wrote:
> On Friday 10 August 2012 19:20:46 Marco Martin wrote:
> > On Friday 10 August 2012, Gregor Tätzner wrote:
> > > I need a nice context menu for kickoff qml. Is someone working on this?
> > > There is a ContextMenu.qml file in plasmacomponents, but it's
> > > kinda...empty.
> > 
> > because it's implemented in c++.
> > 
> > it will create a native qmenu, so should be fine for the use case (items
> > context menu?)
> > 
> > ContextMenu {
> > 
> >       visualParent: contentMenuButton
> >       MenuItem {
> >       
> >            text: "bah"
> >            icon: QIcon("iconname")
> >            onClicked: foo()
> >       
> >       }
> > 
> > }
> 
> Great, working fine so far. But how can I trigger this contextMenu in a
> plasmoid by a right click?
> 
> onClicked: {
> 	if (mouse.button == Qt.RightButton)
> 		...
> 
> doesn't work because the plasmoid settings menu catches the right button.
> Can I overwrite that?

see
http://qt-project.org/doc/qt-4.8/qml-mousearea.html#acceptedButtons-prop

you need to add the rightbutton to the accepted buttons of the mousearea.

the plasmoid right menu should trigger only if no of the child element manages 
the right mouse click event on its own

-- 
Marco Martin


More information about the Plasma-devel mailing list