---
name: "Gtk2::Menu"
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::Menu"
---

# Gtk2::Menu(3pm)

wrapper for GtkMenu

## NAME

Gtk2::Menu - wrapper for GtkMenu

## HIERARCHY

```
  Glib::Object
  +----Glib::InitiallyUnowned
       +----Gtk2::Object
            +----Gtk2::Widget
                 +----Gtk2::Container
                      +----Gtk2::MenuShell
                           +----Gtk2::Menu
```

## INTERFACES

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

## METHODS

### widget = Gtk2::Menu-\>new

### accelgroup = $menu-\>get\_accel\_group

### $menu-\>set\_accel\_group ($accel\_group)

- •

  `$accel_group` (Gtk2::AccelGroup)

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

Since: gtk+ 2.14

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

- •

  `$accel_path` (string)

### widget = $menu-\>get\_active

### $menu-\>set\_active ($index)

- •

  `$index` (integer)

### $menu-\>attach ($child, $left\_attach, $right\_attach, $top\_attach, $bottom\_attach)

- •

  `$child` (Gtk2::Widget)

- •

  `$left_attach` (integer)

- •

  `$right_attach` (integer)

- •

  `$top_attach` (integer)

- •

  `$bottom_attach` (integer)

Since: gtk+ 2.4

### $menu-\>attach\_to\_widget ($attach\_widget, $detach\_func)

- •

  `$attach_widget` (Gtk2::Widget)

- •

  `$detach_func` (scalar)

Attach `$menu` to `$attach_widget`.  `$menu` must not be currently attached to any other widget, including not a submenu of a `"Gtk2::MenuItem"`.

If `$menu` is later detached from the widget with `"$menu->detach"` then the `$detach_func` is called as

```
    &$detach_func ($attach_widget, $menu)
```

### widget = $menu-\>get\_attach\_widget

### $menu-\>detach

### list = Gtk2::Menu-\>get\_for\_attach\_widget ($widget)

- •

  `$widget` (Gtk2::Widget)

Since: gtk+ 2.6

### integer = $menu-\>get\_monitor

Since: gtk+ 2.14

### $menu-\>set\_monitor ($monitor\_num)

- •

  `$monitor_num` (integer)

Since: gtk+ 2.4

### $menu-\>popdown

### $menu-\>popup ($parent\_menu\_shell, $parent\_menu\_item, $menu\_pos\_func, $data, $button, $activate\_time)

- •

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

- •

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

- •

  `$menu_pos_func` (scalar)

- •

  `$data` (scalar)

- •

  `$button` (integer)

- •

  `$activate_time` (integer)

If `$menu_pos_func` is not `"undef"` it's called as

```
    ($x, $y, $push_in) = &$menu_pos_func ($menu, $x, $y, $data)
```

`$x`,`$y` inputs are a proposed position based on the mouse pointer (not actually documented in the Gtk manuals).  The return should be a desired `$x`,`$y`, and an optional `$push_in` flag.  If `$push_in` is true then Gtk will adjust `$x`,`$y` if necessary so the menu is fully visible in the screen width and height.

`$menu_pos_func` and `$data` are stored in `$menu` and may be called again later for a `"$menu->reposition"` or some obscure things like a changed `"set_screen"` while torn-off.  A further `"$menu->popup"` call replaces `$menu_pos_func` and `$data`.

### $menu-\>reorder\_child ($child, $position)

- •

  `$child` (Gtk2::Widget)

- •

  `$position` (integer)

### $menu-\>reposition

### boolean = $menu-\>get\_reserve\_toggle\_size

Since: gtk+ 2.18

### $menu-\>set\_reserve\_toggle\_size ($reserve\_toggle\_size)

- •

  `$reserve_toggle_size` (boolean)

Since: gtk+ 2.18

### $menu-\>set\_screen ($screen)

- •

  `$screen` (Gtk2::Gdk::Screen or undef)

Since: gtk+ 2.2

### boolean = $menu-\>get\_tearoff\_state

### $menu-\>set\_tearoff\_state ($torn\_off)

- •

  `$torn_off` (boolean)

### string = $menu-\>get\_title

### $menu-\>set\_title ($title)

- •

  `$title` (string)

## PROPERTIES

- 'accel-group' (Gtk2::AccelGroup : default undef : readable / writable / private)

  The accel group holding accelerators for the menu

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

  An accel path used to conveniently construct accel paths of child items

- 'active' (integer : default -1 : readable / writable / private)

  The currently selected menu item

- 'attach-widget' (Gtk2::Widget : default undef : readable / writable / private)

  The widget the menu is attached to

- 'monitor' (integer : default -1 : readable / writable / private)

  The monitor the menu will be popped up on

- 'reserve-toggle-size' (boolean : default true : readable / writable / private)

  A boolean that indicates whether the menu reserves space for toggles and icons

- 'tearoff-state' (boolean : default false : readable / writable / private)

  A boolean that indicates whether the menu is torn-off

- 'tearoff-title' (string : default undef : readable / writable / private)

  A title that may be displayed by the window manager when this menu is torn-off

## CHILD PROPERTIES

- 'bottom-attach' (integer : default -1 : readable / writable / private)

  The row number to attach the bottom of the child to

- 'left-attach' (integer : default -1 : readable / writable / private)

  The column number to attach the left side of the child to

- 'right-attach' (integer : default -1 : readable / writable / private)

  The column number to attach the right side of the child to

- 'top-attach' (integer : default -1 : readable / writable / private)

  The row number to attach the top of the child to

## STYLE PROPERTIES

- 'arrow-placement' (Gtk2::ArrowPlacement : default "both" : readable / private)

  Indicates where scroll arrows should be placed

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

  Arbitrary constant to scale down the size of the scroll arrow

- 'double-arrows' (boolean : default true : readable / private)

  When scrolling, always show both arrows.

- 'horizontal-offset' (integer : default -2 : readable / private)

  When the menu is a submenu, position it this number of pixels offset horizontally

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

  Extra space at the left and right edges of the menu

- 'vertical-offset' (integer : default 0 : readable / private)

  When the menu is a submenu, position it this number of pixels offset vertically

- 'vertical-padding' (integer : default 1 : readable / private)

  Extra space at the top and bottom of the menu

## SIGNALS

- **move-scroll** (Gtk2::Menu, Gtk2::ScrollType)

  ## ENUMS AND FLAGS

### enum Gtk2::ScrollType

- •

  'none' / 'GTK\_SCROLL\_NONE'

- •

  'jump' / 'GTK\_SCROLL\_JUMP'

- •

  'step-backward' / 'GTK\_SCROLL\_STEP\_BACKWARD'

- •

  'step-forward' / 'GTK\_SCROLL\_STEP\_FORWARD'

- •

  'page-backward' / 'GTK\_SCROLL\_PAGE\_BACKWARD'

- •

  'page-forward' / 'GTK\_SCROLL\_PAGE\_FORWARD'

- •

  'step-up' / 'GTK\_SCROLL\_STEP\_UP'

- •

  'step-down' / 'GTK\_SCROLL\_STEP\_DOWN'

- •

  'page-up' / 'GTK\_SCROLL\_PAGE\_UP'

- •

  'page-down' / 'GTK\_SCROLL\_PAGE\_DOWN'

- •

  'step-left' / 'GTK\_SCROLL\_STEP\_LEFT'

- •

  'step-right' / 'GTK\_SCROLL\_STEP\_RIGHT'

- •

  'page-left' / 'GTK\_SCROLL\_PAGE\_LEFT'

- •

  'page-right' / 'GTK\_SCROLL\_PAGE\_RIGHT'

- •

  'start' / 'GTK\_SCROLL\_START'

- •

  'end' / 'GTK\_SCROLL\_END'

## SEE ALSO

Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget, Gtk2::Container, Gtk2::MenuShell

## COPYRIGHT

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

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