MenuItem


Object Hierarchy:

Gtk.MenuItem Gtk.MenuItem Gtk.MenuItem Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.MenuItem Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget Gtk.Widget Gtk.Widget->Gtk.Container GLib.InitiallyUnowned GLib.InitiallyUnowned GLib.InitiallyUnowned->Gtk.Widget GLib.Object GLib.Object GLib.Object->GLib.InitiallyUnowned Atk.Implementor Atk.Implementor Atk.Implementor->Gtk.MenuItem Atk.Implementor->Gtk.Bin Atk.Implementor->Gtk.Container Atk.Implementor->Gtk.Widget Gtk.Buildable Gtk.Buildable Gtk.Buildable->Gtk.MenuItem Gtk.Buildable->Gtk.Bin Gtk.Buildable->Gtk.Container Gtk.Buildable->Gtk.Widget Gtk.Actionable Gtk.Actionable Gtk.Actionable->Gtk.MenuItem Gtk.Activatable Gtk.Activatable Gtk.Activatable->Gtk.MenuItem

Description:

[ CCode ( type_id = "gtk_menu_item_get_type ()" ) ]
public class MenuItem : Bin, Implementor, Actionable, Activatable, Buildable

The MenuItem widget and the derived widgets are the only valid children for menus.

Their function is to correctly handle highlighting, alignment, events and submenus.

As a GtkMenuItem derives from Bin it can hold any valid child widget, although only a few are really useful.

By default, a GtkMenuItem sets a AccelLabel as its child. GtkMenuItem has direct functions to set the label and its mnemonic. For more advanced label settings, you can fetch the child widget from the GtkBin.

An example for setting markup and accelerator on a MenuItem:

GtkWidget *menu_item = gtk_menu_item_new_with_label ("Example Menu Item");

GtkWidget *child = gtk_bin_get_child (GTK_BIN (menu_item));
gtk_label_set_markup (GTK_LABEL (child), "<i>new label</i> with <b>markup</b>");
gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), GDK_KEY_1, 0);

GtkMenuItem as GtkBuildable

The GtkMenuItem implementation of the Buildable interface supports adding a submenu by specifying “submenu” as the “type” attribute of a `<child>` element.

An example of UI definition fragment with submenus:

<object class="GtkMenuItem">
<child type="submenu">
<object class="GtkMenu"/>
</child>
</object>

CSS nodes

menuitem
├── <child>
╰── [arrow.right]
m has a single CSS node with name menuitem. If the menuitem has a submenu, it gets another CSS node with name arrow, which has the .left or .right style class.

Namespace: Gtk
Package: gtk+-3.0

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members:

All known members inherited from class Gtk.Bin
All known members inherited from class Gtk.Widget
All known members inherited from class GLib.Object
All known members inherited from interface Atk.Implementor



2022 vala-language.org