[Gtk-sharp-list] Menu.Popup

Jason Boutwell jason.boutwell@comcast.net
06 Oct 2003 11:37:18 -0400


Thanks! That code helped me get it working.

One note for those who have the 2x2 pixel problem when using Gtk.Menu
instead of Glade to create the Menu.

I had that problem too. After you call Menu.Popup(), you should call the
ShowAll() method on the Menu. This will display the MenuItems.

Jason


On Sun, 2003-10-05 at 17:22, McP wrote:
> This code works for me:
> 
> void MouseClick(object o, ButtonPressEventArgs args)
> {
> 	Gdk.EventButton ev = args.Event;
> 	...	
> 	if(ev.button == 3)
> 	{
> 		if(popup_menu == null)
> 		{
> 			Glade.XML gui = new
> Glade.XML(null,"monotageditor.glade","menu1",null);
> 			popup_menu = (Gtk.Menu) gui["menu1"];
>                         ....
> 		}
>                 ...                      
> 		popup_menu.Popup(null,null,null,IntPtr.Zero,ev.button,ev.time);
>                         return;
>                 }
>         }
> 	...
> }
> 
> 
> El vie, 03-10-2003 a las 22:12, Jason Boutwell escribió:
> > I am getting an error when I try to call Menu.Popup().
> > 
> > The docs suggest setting the first four args to null. However, the
> > fourth arg is an IntPtr, which doesn't appreciate being set to null. I
> > tried setting it to IntPtr.Zero, and then it compiled, but generated a
> > null pointer runtime error when executed. It looked to be expecting the
> > func arg to not be null.
> > 
> > The gtk docs suggest that it is ok to set a gpointer to NULL in C,
> > however C# chokes on a null IntPtr. 
> > 
> > A bug perhaps?
> > 
> > Can anyone show me their Popup method call that gets around this.
> > 
> > Thanks!
> > 
> > Jason
> > 
> > 
> > 
> > On Mon, 2003-09-29 at 18:44, John Luke wrote:
> > > Todd Berman wrote:
> > > 
> > > >Has anyone gotten Menu.Popup to work in response to a ButtonPressEvent?
> > > >
> > > > 
> > > >
> > > >Currently, I can get it to 'kinda' work, it popups up a menu that looks
> > > >about 2 x 2 pixels, and doesn't do anything, except go away like it should.
> > > >
> > > >  
> > > >
> > > Yeah, I was seeing that also when I first was trying Gnome.Popup, I 
> > > worked around it by creating the menu in glade, and then attaching it.  
> > > My guess is that Gtk.Menu.Popup could be done in a similar way.  I 
> > > haven't looked into it any more though.
> > > 
> > > _______________________________________________
> > > Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> > 
> > _______________________________________________
> > Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list