---
name: "Gtk2::MenuItem"
section: "3pm"
platform: "linux"
package: "libgtk2-perl-doc"
version: "2:1.24992-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Gtk2::MenuItem"
---

# Gtk2::MenuItem(3pm)

wrapper for GtkMenuItem

## NAME

Gtk2::MenuItem - wrapper for GtkMenuItem

## DESCRIPTION

If a MenuItem is created with a `$label` string, or if the `"label"` property is set later, then it should be destroyed with `"$item->destroy"`.  Just dropping the last Perl ref is not enough because (as of Gtk through to 2.18) there's a circular reference from the child `"Gtk2::AccelLabel"` back up to the item (the `"accel-widget"` property).

When a MenuItem is in a `"Gtk2::Menu"` a `"destroy"` happens automatically.  Dropping the last ref to a Menu calls `"destroy"` on its children, as usual for a container.  But if you remove a MenuItem with a label from a menu (or never add it to one) then be sure to `"$item->destroy"` explicitly.

## HIERARCHY

```
  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::Container
                      +----Gtk2::Bin
                           +----Gtk2::Item
                                +----Gtk2::MenuItem
```

## INTERFACES

```
  Glib::Object::_Unregistered::AtkImplementorIface
  Gtk2::Buildable
  Gtk2::Activatable
```

## METHODS

### widget = Gtk2::MenuItem-\>new ($label=undef)

- •

  `$label` (string)

If a `$label` argument is given then this is `"new_with_mnemonic"`.

### widget = Gtk2::MenuItem-\>new\_with\_label ($label=undef)

- •

  `$label` (string)

### widget = Gtk2::MenuItem-\>new\_with\_mnemonic ($label=undef)

- •

  `$label` (string)

### string = $menu\_item-\>get\_accel\_path

Since: gtk+ 2.14

### $menu\_item-\>set\_accel\_path ($accel\_path)

- •

  `$accel_path` (string)

### $menu\_item-\>activate

### $menu\_item-\>deselect

### string = $menu\_item-\>get\_label

Since: gtk+ 2.16

### $menu\_item-\>set\_label ($label)

- •

  `$label` (string)

Since: gtk+ 2.16

### $menu\_item-\>remove\_submenu

### boolean = $menu\_item-\>get\_right\_justified

### $menu\_item-\>set\_right\_justified ($right\_justified)

- •

  `$right_justified` (boolean)

### $menu\_item-\>select

### widget or undef = $menu\_item-\>get\_submenu

### $menu\_item-\>set\_submenu ($submenu)

- •

  `$submenu` (Gtk2::Widget or undef)

### $menu\_item-\>toggle\_size\_allocate ($allocation)

- •

  `$allocation` (integer)

### requisition = $menu\_item-\>toggle\_size\_request

### boolean = $menu\_item-\>get\_use\_underline

Since: gtk+ 2.16

### $menu\_item-\>set\_use\_underline ($use\_underline)

- •

  `$use_underline` (boolean)

Since: gtk+ 2.16

## PROPERTIES

- 'accel-path' (string : default undef : readable / writable / private)

  Sets the accelerator path of the menu item

- 'label' (string : default "" : readable / writable / private)

  The text for the child label

- 'right-justified' (boolean : default false : readable / writable / private)

  Sets whether the menu item appears justified at the right side of a menu bar

- 'submenu' (Gtk2::Menu : default undef : readable / writable / private)

  The submenu attached to the menu item, or NULL if it has none

- 'use-underline' (boolean : default false : readable / writable / private)

  If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key

## STYLE PROPERTIES

- 'arrow-scaling' (float : default 0.8 : readable / private)

  Amount of space used up by arrow, relative to the menu item's font size

- 'arrow-spacing' (integer : default 10 : readable / private)

  Space between label and arrow

- 'horizontal-padding' (integer : default 3 : readable / private)

  Padding to left and right of the menu item

- 'selected-shadow-type' (Gtk2::ShadowType : default "none" : readable / private)

  Shadow type when item is selected

- 'toggle-spacing' (integer : default 5 : readable / private)

  Space between icon and label

- 'width-chars' (integer : default 12 : readable / private)

  The minimum desired width of the menu item in characters

## SIGNALS

- **activate** (Gtk2::MenuItem)

  - **activate-item** (Gtk2::MenuItem)

  - **toggle-size-allocate** (Gtk2::MenuItem, integer)

  - **toggle-size-request** (Gtk2::MenuItem, gpointer)

  ## SEE ALSO

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container, Gtk2::Bin, Gtk2::Item

## COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL.  See Gtk2 for a full notice.
