[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KActions in context menus
From:       Alexander Brand <alinx () gmx ! de>
Date:       2001-11-06 22:08:01
[Download RAW message or body]

On Monday, 24. September 2001 18:14 Kurt Granroth wrote:

Hello,

> On Sunday 23 September 2001 02:45 pm, Dmitry Samoyloff wrote:
> > Tell me please, can I deal with KActions in the context menus
> > somehow, or should I use old-style callbacks with IDs?
>
> Yes, you can use KActions in context menus!  It's not *quite* as easy as
> normal menus, but it's not hard either.
>
> 1. Your XML file should look *something* like this.  Note that your context
> menu should be OUTSIDE of the MenuBar
>
>    [sniped code]
>
> 2. Instantiate your actions like normal:
>
>    new KAction( i18n("My Context Action"), ...., "some_context_action" );
>
> 3. Get a handle on your popup menu:
>
>   void Blah::mousePressEvent(QMouseEvent* e)
>   {
>     if ( e->button() != RightButton )
>       return;
>
>     QWidget *widget( factory()->container( "popupmenu", this ) );

I try to implement this in a KPart. But I didn't get any 'factory()'. The 
only factory (Type: KXMLGUIClient) I found was in KPart::MainWindow.
But how can I implement it? Please, can somebody help?

>     if ( !widget || !widget->inherits( "KPopupMenu" ) )
>       return;
>
>     KPopupMenu *menu( static_cast<KPopupMenu*>(widget) );
>     menu->popup( ... )
>   }

Thanks,
    Alex Brand
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic