Gtk.Menu
const Gtk = imports.gi.Gtk; let menu = new Gtk.Menu({ accel_group: value, accel_path: value, active: value, attach_widget: value, monitor: value, reserve_toggle_size: value, tearoff_state: value, tearoff_title: value, });
A Gtk.Menu is a Gtk.MenuShell that implements a drop down menu consisting of a list of Gtk.MenuItem objects which can be navigated and activated by the user to perform application functions.
A Gtk.Menu is most commonly dropped down by activating a Gtk.MenuItem in a Gtk.MenuBar or popped up by activating a Gtk.MenuItem in another Gtk.Menu.
A Gtk.Menu can also be popped up by activating a Gtk.ComboBox. Other composite widgets such as the Gtk.Notebook can pop up a Gtk.Menu as well.
Applications can display a Gtk.Menu as a popup menu by calling the Gtk.popup function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.
<example> <title>Connecting the popup signal handler.</title> <programlisting> /<!---->* connect our handler which will popup the menu *<!---->/ g_signal_connect_swapped (window, "button_press_event", G_CALLBACK (my_popup_handler), menu); </programlisting> </example>
<example> <title>Signal handler which displays a popup menu.</title> <programlisting> static gint my_popup_handler (GtkWidget *widget, GdkEvent *event) { GtkMenu *menu; GdkEventButton *event_button;
g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE);
/<!---->* The "widget" is the menu that was supplied when * g_signal_connect_swapped() was called. *<!---->/ menu = GTK_MENU (widget);
if (event->type == GDK_BUTTON_PRESS) { event_button = (GdkEventButton *) event; if (event_button->button == GDK_BUTTON_SECONDARY) { gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, event_button->time); return TRUE; } }
return FALSE; } </programlisting> </example>
Hierarchy
-
GObject.Object
-
GObject.InitiallyUnowned
-
Gtk.Widget
-
Gtk.Container
-
Gtk.MenuShell
- Gtk.Menu
-
-
-
-
Methods
- Gtk.Menu.prototype.attach
- Gtk.Menu.prototype.attach_to_widget
- Gtk.Menu.prototype.detach
- Gtk.Menu.prototype.get_accel_group
- Gtk.Menu.prototype.get_accel_path
- Gtk.Menu.prototype.get_active
- Gtk.Menu.prototype.get_attach_widget
- Gtk.Menu.prototype.get_monitor
- Gtk.Menu.prototype.get_reserve_toggle_size
- Gtk.Menu.prototype.get_tearoff_state
- Gtk.Menu.prototype.get_title
- Gtk.Menu.prototype.popdown
- Gtk.Menu.prototype.popup
- Gtk.Menu.prototype.popup_for_device
- Gtk.Menu.prototype.reorder_child
- Gtk.Menu.prototype.reposition
- Gtk.Menu.prototype.set_accel_group
- Gtk.Menu.prototype.set_accel_path
- Gtk.Menu.prototype.set_active
- Gtk.Menu.prototype.set_monitor
- Gtk.Menu.prototype.set_reserve_toggle_size
- Gtk.Menu.prototype.set_screen
- Gtk.Menu.prototype.set_tearoff_state
- Gtk.Menu.prototype.set_title