On Sat, 2003-10-18 at 12:39, Alex Roitman wrote:
> 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?

You could pad the top of the menu with an item consisting of an empty
string.

> 
> Any help would be greatly appreciated!
> 
> Thanks in advance,
> Alex
-- 
Steve McClure <[EMAIL PROTECTED]>
Racemi, Inc.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
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