<Type Name="Menu" FullName="Gtk.Menu"> <TypeSignature Language="C#" Maintainer="Hector Gomez M" Value="public class Menu : Gtk.MenuShell" /> <AssemblyInfo> <AssemblyName>gtk-sharp</AssemblyName> <AssemblyPublicKey> </AssemblyPublicKey> <AssemblyVersion>2.10.0.0</AssemblyVersion> </AssemblyInfo> <ThreadSafetyStatement>Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.</ThreadSafetyStatement> <Docs> <summary>A <see cref="T:Gtk.Menu" /> is a <see cref="T:Gtk.MenuShell" /> that implements a drop down menu.</summary> <remarks> <para> A <see cref="T:Gtk.Menu" /> is a <see cref="T:Gtk.MenuShell" /> that implements a drop down menu consisting of a list of <see cref="T:Gtk.MenuItem" /> objects which can be navigated and activated by the user to perform application functions. </para> <para> It is commonly dropped down by activating a <see cref="T:Gtk.MenuItem" /> in a <see cref="T:Gtk.MenuBar" /> or in another <see cref="T:Gtk.Menu" />, it can also be popped up by activating a <see cref="T:Gtk.OptionMenu" />. Other composite widgets such as the <see cref="T:Gtk.Notebook" /> can pop up a <see cref="T:Gtk.Menu" /> as well. </para> <example> <code lang="C#"> using System; using Gtk; public class MenuApp { public static void Main (string[] args) { Application.Init(); Window win = new Window ("Menu Sample App"); win.DeleteEvent += new DeleteEventHandler (delete_cb); win.SetDefaultSize (200, 150); VBox box = new VBox (false, 2); MenuBar mb = new MenuBar (); Menu file_menu = new Menu (); MenuItem exit_item = new MenuItem("Exit"); exit_item.Activated += new EventHandler (exit_cb); file_menu.Append (exit_item); MenuItem file_item = new MenuItem("File"); file_item.Submenu = file_menu; mb.Append (file_item); box.PackStart(mb, false, false, 0); Button btn = new Button ("Yep, that's a menu"); box.PackStart(btn, true, true, 0); win.Add (box); win.ShowAll (); Application.Run (); } static void delete_cb (object o, DeleteEventArgs args) { Application.Quit (); } static void exit_cb (object o, EventArgs args) { Application.Quit (); } } </code> </example> </remarks> </Docs> <Base> <BaseTypeName>Gtk.MenuShell</BaseTypeName> </Base> <Interfaces> </Interfaces> <Attributes> <Attribute> <AttributeName>System.Reflection.DefaultMember("Item")</AttributeName> </Attribute> </Attributes> <Members> <Member MemberName="Detach"> <MemberSignature Language="C#" Value="public void Detach ();" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>Detaches the menu from the widget to which it had been attached.</summary> <remarks> <para> This function will call the detacher, provided when the <see cref="M:Gtk.Menu.AttachToWidget" /> function was called. </para> </remarks> </Docs> </Member> <Member MemberName="Popdown"> <MemberSignature Language="C#" Value="public void Popdown ();" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>Removes the menu from the screen.</summary> <remarks /> </Docs> </Member> <Member MemberName="AttachToWidget"> <MemberSignature Language="C#" Value="public void AttachToWidget (Gtk.Widget attach_widget, Gtk.MenuDetachFunc detacher);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="attach_widget" Type="Gtk.Widget" /> <Parameter Name="detacher" Type="Gtk.MenuDetachFunc" /> </Parameters> <Docs> <summary>Attaches the menu to the widget and provides a detacher.</summary> <param name="attach_widget">The <see cref="T:Gtk.Widget" /> that the menu will be attached to.</param> <param name="detacher">The user supplied callback function that will be called when the menu calls <see cref="M:Gtk.Menu.Detach" />.</param> <remarks> <para> Attaches the menu to the widget and provides a callback function that will be invoked when the menu calls <see cref="M:Gtk.Menu.Detach" /> during its destruction. </para> </remarks> </Docs> </Member> <Member MemberName="Popup"> <MemberSignature Language="C#" Value="public void Popup ();" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>Displays a menu and makes it available for selection.</summary> <remarks>This is a convenience overload that calls <see cref="M:Gtk.Menu.Popup(Gtk.Widget,Gtk.Widget,Gtk.MenuPositionFunc,System.IntPtr,System.UInt32,System.UInt32)" /> with some default arguments.</remarks> </Docs> </Member> <Member MemberName="Popup"> <MemberSignature Language="C#" Value="public void Popup (Gtk.Widget parent_menu_shell, Gtk.Widget parent_menu_item, Gtk.MenuPositionFunc func, uint button, uint activate_time);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="parent_menu_shell" Type="Gtk.Widget" /> <Parameter Name="parent_menu_item" Type="Gtk.Widget" /> <Parameter Name="func" Type="Gtk.MenuPositionFunc" /> <Parameter Name="button" Type="System.UInt32" /> <Parameter Name="activate_time" Type="System.UInt32" /> </Parameters> <Docs> <summary>Displays a menu and makes it available for selection.</summary> <param name="parent_menu_shell">The menu shell containing the triggering menu item, or <see langword="null" />.</param> <param name="parent_menu_item">The menu item whose activation triggered the popup, or <see langword="null" />.</param> <param name="func">A user supplied function used to position the menu, or <see langword="null" />.</param> <param name="button">The mouse button which was pressed to initiate the event.</param> <param name="activate_time">The time at which the activation event occurred.</param> <remarks> <para> Applications can use this function to display context-sensitive menus, and will typically supply <see langword="null" /> for the <paramref name="parent_menu_shell" />, <paramref name="parent_menu_item" />, and <paramref name="func" /> parameters. The default menu positioning function will position the menu at the current mouse cursor position. </para> <para> The <paramref name="button" /> parameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress, button should be zero(0). </para> <para> The <paramref name="activate_time" /> parameter should be the time stamp of the event that initiated the popup. If such an event is not available, use <see cref="P:Gtk.Global.CurrentEventTime" /> instead. </para> </remarks> <example> <code language="C#"> using System; using Gtk; class PopupSample { Window win; Menu menu; static void Main (string[] args) { new PopupSample (args); } PopupSample (string[] args) { Application.Init (); win = new Window ("Menu.Popup sample"); win.SetDefaultSize (400, 300); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); 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.ButtonPressEvent += new ButtonPressEventHandler (OnEventBoxPressed); eventbox.Add (label); win.Add (eventbox); win.ShowAll (); Application.Run (); } private void OnEventBoxPressed (object o, ButtonPressEventArgs args) { if (args.Event.button == 3) menu.Popup (null, null, null, 3, Gtk.Global.CurrentEventTime); } private void OnHelloActivated (object o, EventArgs args) { Console.WriteLine ("Hello Activated"); } private void OnWinDelete (object o, DeleteEventArgs args) { Application.Quit (); } } </code> </example> </Docs> </Member> <Member MemberName="Popup"> <MemberSignature Language="C#" Value="public void Popup (Gtk.Widget parent_menu_shell, Gtk.Widget parent_menu_item, Gtk.MenuPositionFunc func, IntPtr data, uint button, uint activate_time);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="parent_menu_shell" Type="Gtk.Widget" /> <Parameter Name="parent_menu_item" Type="Gtk.Widget" /> <Parameter Name="func" Type="Gtk.MenuPositionFunc" /> <Parameter Name="data" Type="System.IntPtr" /> <Parameter Name="button" Type="System.UInt32" /> <Parameter Name="activate_time" Type="System.UInt32" /> </Parameters> <Docs> <summary>Obsolete. Replaced by <see cref="Gtk.Menu.Popup(Gtk.Widget,Gtk.Widget,Gtk.MenuPositionFunc,System.UInt32,System.UInt32)" />.</summary> <param name="parent_menu_shell">The menu shell containing the triggering menu item, or <see langword="null" />.</param> <param name="parent_menu_item">The menu item whose activation triggered the popup, or <see langword="null" />.</param> <param name="func">A user supplied function used to position the menu, or <see langword="null" />.</param> <param name="data">Ignored.</param> <param name="button">The mouse button which was pressed to initiate the event.</param> <param name="activate_time">The time at which the activation event occurred.</param> <remarks /> </Docs> </Member> <Member MemberName="Reposition"> <MemberSignature Language="C#" Value="public void Reposition ();" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>Repositions the menu according to its position function.</summary> <remarks /> </Docs> </Member> <Member MemberName="ReorderChild"> <MemberSignature Language="C#" Value="public void ReorderChild (Gtk.Widget child, int position);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="child" Type="Gtk.Widget" /> <Parameter Name="position" Type="System.Int32" /> </Parameters> <Docs> <summary>Moves a <see cref="T:Gtk.MenuItem" /> to a new position within the <see cref="T:Gtk.Menu" />.</summary> <param name="child">The <see cref="T:Gtk.MenuItem" /> to move.</param> <param name="position">The new position to place <paramref name="child" />. Positions are numbered from 0 to n-1.</param> <remarks /> </Docs> </Member> <Member MemberName=".ctor"> <MemberSignature Language="C#" Value="public Menu (IntPtr raw);" /> <MemberType>Constructor</MemberType> <ReturnValue /> <Parameters> <Parameter Name="raw" Type="System.IntPtr" /> </Parameters> <Docs> <summary>Internal constructor</summary> <param name="raw">Pointer to the C object.</param> <remarks> <para>This is an internal constructor, and should not be used by user code.</para> </remarks> </Docs> </Member> <Member MemberName=".ctor"> <MemberSignature Language="C#" Value="public Menu ();" /> <MemberType>Constructor</MemberType> <ReturnValue /> <Parameters /> <Docs> <summary>A constructor.</summary> <remarks /> </Docs> </Member> <Member MemberName="Active"> <MemberSignature Language="C#" Value="public Gtk.Widget Active { get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>Gtk.Widget</ReturnType> </ReturnValue> <Docs> <summary>Returns the selected menu item from the menu.</summary> <value>The <see cref="T:Gtk.MenuItem" /> that was last selected in the menu. If a selection has not yet been made, the first menu item is selected.</value> <remarks> <para> This is used by the <see cref="T:Gtk.OptionMenu" />. </para> </remarks> </Docs> </Member> <Member MemberName="AccelPath"> <MemberSignature Language="C#" Value="public string AccelPath { set; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>System.String</ReturnType> </ReturnValue> <Parameters> </Parameters> <Docs> <summary>Sets an accelerator path for this menu from which accelerator paths for its immediate children, its menu items, can be constructed.</summary> <value>void</value> <remarks> <para> The main purpose of this function is to spare the programmer the inconvenience of having to call <see cref="P:Gtk.MenuItem.AccelPath" /> on each menu item that should support runtime user changable accelerators. Instead, by just calling <see cref="P:Gtk.MenuItem.AccelPath" /> on their parent, each menu item of this menu, that contains a label describing its purpose, automatically gets an accel path assigned. </para> </remarks> </Docs> </Member> <Member MemberName="AttachWidget"> <MemberSignature Language="C#" Value="public Gtk.Widget AttachWidget { get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>Gtk.Widget</ReturnType> </ReturnValue> <Docs> <summary>Returns the <see cref="T:Gtk.Widget" /> that the menu is attached to.</summary> <value>The <see cref="T:Gtk.Widget" /> that the menu is attached to.</value> <remarks /> </Docs> </Member> <Member MemberName="TearoffState"> <MemberSignature Language="C#" Value="public bool TearoffState { set; get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>System.Boolean</ReturnType> </ReturnValue> <Parameters> </Parameters> <Docs> <summary>Sets or obtains the tearoff state of the menu.</summary> <value>Returns <see langword="true" /> if the menu is currently torn off.</value> <remarks> <para> A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached. </para> </remarks> </Docs> <Attributes> <Attribute> <AttributeName>GLib.Property("tearoff-state")</AttributeName> </Attribute> </Attributes> </Member> <Member MemberName="AccelGroup"> <MemberSignature Language="C#" Value="public Gtk.AccelGroup AccelGroup { set; get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>Gtk.AccelGroup</ReturnType> </ReturnValue> <Parameters> </Parameters> <Docs> <summary>Sets or obtains the <see cref="T:Gtk.AccelGroup" /> which holds global accelerators for the menu.</summary> <value>The <see cref="T:Gtk.AccelGroup" /> associated with the menu.</value> <remarks> <para> This accelerator group needs to also be added to all windows that this menu is being used in with <see cref="M:Gtk.Window.AddAccelGroup" />, in order for those windows to support all the accelerators contained in this group. </para> </remarks> </Docs> </Member> <Member MemberName="Title"> <MemberSignature Language="C#" Value="public string Title { set; get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>System.String</ReturnType> </ReturnValue> <Parameters> </Parameters> <Docs> <summary>Sets or obtains the title for the menu.</summary> <value>The title of the menu, or <see langword="null" /> if the menu has no title set on it. This string is owned by the widget and should not be modified or freed.</value> <remarks> <para> The title is displayed when the menu is shown as a tearoff menu. </para> </remarks> </Docs> </Member> <Member MemberName="TearoffTitle"> <MemberSignature Language="C#" Value="public string TearoffTitle { set; get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>System.String</ReturnType> </ReturnValue> <Parameters> </Parameters> <Docs> <summary>The title of this menu when it is torn off</summary> <value>an object of type <see cref="T:System.String" /></value> <remarks /> </Docs> <Attributes> <Attribute> <AttributeName>GLib.Property("tearoff-title")</AttributeName> </Attribute> </Attributes> </Member> <Member MemberName="Screen"> <MemberSignature Language="C#" Value="public Gdk.Screen Screen { set; get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>Gdk.Screen</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>The physical screen this menu is placed on.</summary> <value>a <see cref="T:Gdk.Screen" /></value> <remarks /> </Docs> </Member> <Member MemberName="SetActive"> <MemberSignature Language="C#" Value="public void SetActive (uint index_);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="index_" Type="System.UInt32" /> </Parameters> <Docs> <summary>Selects the specified menu item within the menu.</summary> <param name="index_">a <see cref="T:System.UInt32" /></param> <remarks> <para> This is used by the <see cref="T:Gtk.OptionMenu" /> and should not be used by anyone else. </para> </remarks> </Docs> </Member> <Member MemberName="GType"> <MemberSignature Language="C#" Value="public static GLib.GType GType { get; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>GLib.GType</ReturnType> </ReturnValue> <Parameters /> <Docs> <summary>GType Property.</summary> <value>a <see cref="T:GLib.GType" /></value> <remarks>Returns the native <see cref="T:GLib.GType" /> value for <see cref="T:Gtk.Menu" />.</remarks> </Docs> </Member> <Member MemberName=".ctor"> <MemberSignature Language="C#" Value="protected Menu (GLib.GType gtype);" /> <MemberType>Constructor</MemberType> <ReturnValue /> <Parameters> <Parameter Name="gtype" Type="GLib.GType" /> </Parameters> <Docs> <summary>Protected Constructor.</summary> <param name="gtype">a <see cref="T:GLib.GType" /></param> <remarks>Chain to this constructor if you have manually registered a native <see cref="T:GLib.GType" /> value for your subclass.</remarks> </Docs> <Attributes> <Attribute> <AttributeName>System.Obsolete</AttributeName> </Attribute> </Attributes> </Member> <Member MemberName="Monitor"> <MemberSignature Language="C#" Value="public int Monitor { set; };" /> <MemberType>Property</MemberType> <ReturnValue> <ReturnType>System.Int32</ReturnType> </ReturnValue> <Docs> <summary>The number of the monitor on which the menu should be popped up.</summary> <value>a <see cref="T:System.Int32" /></value> <remarks> </remarks> <since version="Gtk# 2.4" /> </Docs> </Member> <Member MemberName="Attach"> <MemberSignature Language="C#" Value="public void Attach (Gtk.Widget child, uint left_attach, uint right_attach, uint top_attach, uint bottom_attach);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> <Parameters> <Parameter Name="child" Type="Gtk.Widget" /> <Parameter Name="left_attach" Type="System.UInt32" /> <Parameter Name="right_attach" Type="System.UInt32" /> <Parameter Name="top_attach" Type="System.UInt32" /> <Parameter Name="bottom_attach" Type="System.UInt32" /> </Parameters> <Docs> <summary>Adds a new <see cref="T:Gtk.MenuItem" /> to a (table) menu.</summary> <param name="child">a <see cref="T:Gtk.Widget" />, should be a <see cref="T:Gtk.MenuItem" /></param> <param name="left_attach">a <see cref="T:System.UInt32" /></param> <param name="right_attach">a <see cref="T:System.UInt32" /></param> <param name="top_attach">a <see cref="T:System.UInt32" /></param> <param name="bottom_attach">a <see cref="T:System.UInt32" /></param> <remarks> <para>The number of 'cells' that an item will occupy is specified by <paramref name="left_attach" />, <paramref name="right_attach" />, <paramref name="top_attach" /> and <paramref name="bottom_attach" />. These each represent the leftmost, rightmost, uppermost and lower column and row numbers of the table. (Columns and rows are indexed from zero).</para> <para>Note that this function is not related to <see cref="M:Gtk.Menu.Detach" />.</para> </remarks> <since version="Gtk# 2.4" /> </Docs> </Member> <Member MemberName="GetForAttachWidget"> <MemberSignature Language="C#" Value="public static GLib.List GetForAttachWidget (Gtk.Widget widget);" /> <MemberType>Method</MemberType> <ReturnValue> <ReturnType>GLib.List</ReturnType> </ReturnValue> <Parameters> <Parameter Name="widget" Type="Gtk.Widget" /> </Parameters> <Docs> <summary>To be added</summary> <param name="widget">a <see cref="T:Gtk.Widget" /></param> <returns>a <see cref="T:GLib.List" /></returns> <remarks>To be added</remarks> <since version="Gtk# 2.6" /> </Docs> </Member> </Members> </Type>