gnome-sharp 2.0.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. Create and display popup and context menus. using System; using Gtk; using GtkSharp; using Gnome; class PopupSample { Program program; static void Main (string[] args) { new PopupSample (args); } PopupSample (string[] args) { program = new Program ("PopupSample", "0.0", Modules.UI, args); App app = new App ("PopupSample", "Gnome.Popup sample"); app.SetDefaultSize (400, 300); app.DeleteEvent += new DeleteEventHandler (OnAppDelete); Menu menu = new Menu (); MenuItem hello = new MenuItem ("Hello"); hello.Activated += new EventHandler (OnHelloActivated); hello.Show (); menu.Append (hello); Label label = new Label ("Right Click me"); EventBox eventbox = new EventBox (); eventbox.Add (label); app.Contents = eventbox; Popup.MenuAttach (menu, eventbox, IntPtr.Zero); app.ShowAll (); program.Run (); } private void OnHelloActivated (object o, EventArgs args) { Console.WriteLine ("Hello Activated"); } private void OnAppDelete (object o, DeleteEventArgs args) { program.Quit (); } } System.Object Method Gtk.Widget Creates a popup menu out of the specified array. a a This method behaves just like , except that it creates an for you and attaches it to the menu object. Use to get the that is created. Method System.Void You can use this function to pop up a menu. a a a a a a When a menu item callback is invoked, the specified user_data will be passed to it. The and parameters are the same as for , i.e. you can use them to specify a function to position the menu explicitly. If you want the default position (near the mouse), pass for these parameters. The event parameter is needed to figure out the mouse button that activated the menu and the time at which this happened. If you pass in , then no button and the current time will be used as defaults. Method Gtk.Widget Creates a popup menu out of the specified array. a a a Use to pop the menu up, or attach it to a window with . Method Gtk.AccelGroup This function is used to retrieve the accelgroup that was created by . a a If you want to specify the accelgroup that the popup menu accelerators use, then use . Method System.Void Appends the menu items in to the menu. a a Method System.Void Attaches the specified menu to the specified . a a a The menu can then be activated by pressing mouse button 3 over the widget. When a menu item callback is invoked, the specified will be passed to it. This function requires the widget to have its own window (i.e. ), This function will try to set the flag on the event mask for the widget if it does not have it yet. If this is the case, then the widget must not be realized for it to work. The popup menu can be attached to different widgets at the same time. A reference count is kept on the popup menu; when all the widgets it is attached to are destroyed, the popup menu will be destroyed as well. Under the current implementation, setting a popup menu for a widget and then reparenting that widget will cause Bad Things to happen. Method System.Int32 You can use this function to pop up a menu modally. a a a a a a a Same as , but modal. Constructor Creates a new instance. The default constructor for .