Hello,

I have another silly question, hopefully a piece of cake for everybody 
on the list.

I am setting up a context menu which pops up upon the right click.
This is how I do it:

    mywidget.connect('button-press-event',self.button_press)

    def button_press(self,obj,event):
        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
            self.build_context_menu()

    def build_context_menu(self):
        entries = [
            (gtk.STOCK_ADD, self.on_add_clicked,1),
            (gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity),
            (_("Edit"), self.on_edit_clicked,sel_sensitivity),
        ]

        menu = gtk.Menu()
        for stock_id,callback,sensitivity in entries:
            item = gtk.ImageMenuItem(stock_id)
            if callback:
                item.connect("activate",callback)
            item.set_sensitive(sensitivity)
            item.show()
            menu.append(item)
        menu.popup(None,None,None,0,0)


Everything works just fine except for one annoying thing. If you 
right-click and then immediately let go (no holding the right mouse button), 
then the menu pops up and the first item immediately gets selected. 
I would like instead to have the menu poped up until the items is 
chosen in this case, just like the web browsers do it.
Is this a different event? How do I catch it?

Interestingly, if the first item is not sensitive, then the menu behaves 
the way I want it. Can I make it "behave" in all cases?

Any help would be greatly appreciated!

Thanks in advance,
Alex

-- 
Alexander Roitman   http://ebner.neuroscience.umn.edu/people/alex.html
Dept. of Neuroscience, Lions Research Building
2001 6th Street SE, Minneapolis, MN  55455
Tel (612) 625-7566   FAX (612) 626-9201

Attachment: signature.asc
Description: Digital signature

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to