plasma components ContextMenu

Gregor Tätzner gregor at freenet.de
Tue Aug 14 19:21:24 UTC 2012


On Sunday 12 August 2012 12:51:19 Marco Martin wrote:
> 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

excellent :)

One last issue: What would be the best approach to align the context menu 
popup to the mouse pointer? As it stands now the menu pops below the 
visualParent of the ContextMenu (in my case a list entry)

Greg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120814/a84c9da8/attachment.sig>


More information about the Plasma-devel mailing list