A menu widget

Methods and Functions

gtkMenuNew(show = TRUE) gtkMenuSetScreen(object, screen = NULL) gtkMenuReorderChild(object, child, position) gtkMenuAttach(object, child, left.attach, right.attach, top.attach, bottom.attach) gtkMenuPopup(object, = NULL, = NULL, func = NULL, data = NULL, button, activate.time) gtkMenuSetAccelGroup(object, gtkMenuGetAccelGroup(object) gtkMenuSetAccelPath(object, accel.path) gtkMenuGetAccelPath(object) gtkMenuSetTitle(object, title) gtkMenuGetTitle(object) gtkMenuSetMonitor(object, monitor.num) gtkMenuGetMonitor(object) gtkMenuGetTearoffState(object) gtkMenuSetReserveToggleSize(object, reserve.toggle.size) gtkMenuGetReserveToggleSize(object) gtkMenuPopdown(object) gtkMenuReposition(object) gtkMenuGetActive(object) gtkMenuSetActive(object, index) gtkMenuSetTearoffState(object, gtkMenuAttachToWidget(object, attach.widget) gtkMenuDetach(object) gtkMenuGetAttachWidget(object) gtkMenuGetForAttachWidget(object) gtkMenu(show = TRUE)




GtkMenu implements AtkImplementorIface and GtkBuildable.

Detailed Description

A GtkMenu is a GtkMenuShell that implements a drop down menu consisting of a list of GtkMenuItem objects which can be navigated and activated by the user to perform application functions. A GtkMenu is most commonly dropped down by activating a GtkMenuItem in a GtkMenuBar or popped up by activating a GtkMenuItem in another GtkMenu. A GtkMenu can also be popped up by activating a GtkOptionMenu. Other composite widgets such as the GtkNotebook can pop up a GtkMenu as well. Applications can display a GtkMenu as a popup menu by calling the gtkMenuPopup function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed. Connecting the popup signal handler.

## connect our handler which will popup the menu 
gSignalConnect(window, "button_press_event", my_popup_handler, menu,
Signal handler which displays a popup menu.
# The popup handler
my_popup_handler <- function(widget, event)
  stopifnot(widget != NULL)
  checkPtrType(widget, "GtkMenu")
  stopifnot(event != NULL) ## The "widget" is the menu that was supplied when 
  ## gSignalConnect() was called.
  menu <- widget if (event[["type"]] == "button-press") {
    if (event[["button"]] == 3) {
      menu$popup(button=event[["button"]], activate.time=event[["time"]])
  } return(FALSE)


Convenient Construction

gtkMenu is the equivalent of gtkMenuNew.

User Functions

GtkMenuPositionFunc(menu, x, y,,
A user function supplied when calling gtkMenuPopup which controls the positioning of the menu when it is displayed. The function sets the x and y parameters to the coordinates where the menu is to be drawn. To make the menu appear on a different monitor than the mouse pointer, gtkMenuSetMonitor must be called.
a GtkMenu.
the integer representing the horizontal position where the menu shall be drawn. This is an output parameter.
the integer representing the vertical position where the menu shall be drawn. This is an output parameter.
This parameter controls how menus placed outside the monitor are handled. If this is set to TRUE and part of the menu is outside the monitor then GTK+ pushes the window into the visible area, effectively modifying the popup position. Note that moving and possibly resizing the menu around will alter the scroll position to keep the menu items "in place", i.e. at the same monitor position they would have been without resizing. In practice, this behavior is only useful for combobox popups or option menus and cannot be used to simply confine a menu to monitor boundaries. In that case, changing the scroll offset is not desirable.
the data supplied by the user in the gtkMenuPopup data parameter.
GtkMenuDetachFunc(attach.widget, menu)
A user function supplied when calling gtkMenuAttachToWidget which will be called when the menu is later detached from the widget.
the GtkWidget that the menu is being detached from.
the GtkMenu being detached.



accel-group [GtkAccelGroup : * : Read / Write]
The accel group holding accelerators for the menu. Since 2.14
accel-path [character : * : Read / Write]
An accel path used to conveniently construct accel paths of child items. Default value: NULL Since 2.14
active [integer : Read / Write]
The index of the currently selected menu item, or -1 if no menu item is selected. Allowed values: >= -1 Default value: -1 Since 2.14
attach-widget [GtkWidget : * : Read / Write]
The widget the menu is attached to. Setting this property attaches the menu without a GtkMenuDetachFunc. If you need to use a detacher, use gtkMenuAttachToWidget directly. Since 2.14
monitor [integer : Read / Write]
The monitor the menu will be popped up on. Allowed values: >= -1 Default value: -1 Since 2.14
reserve-toggle-size [logical : Read / Write]
A boolean that indicates whether the menu reserves space for toggles and icons, regardless of their actual presence. This property should only be changed from its default value for special-purposes such as tabular menus. Regular menus that are connected to a menu bar or context menus should reserve toggle space for consistency. Default value: TRUE Since 2.18
tearoff-state [logical : Read / Write]
A boolean that indicates whether the menu is torn-off. Default value: FALSE Since 2.6
tearoff-title [character : * : Read / Write]
A title that may be displayed by the window manager when this menu is torn-off. Default value: NULL

Style Properties

arrow-placement [GtkArrowPlacement : Read]
Indicates where scroll arrows should be placed. Default value: GTK_ARROWS_BOTH Since 2.16
arrow-scaling [numeric : Read]
Arbitrary constant to scale down the size of the scroll arrow. Allowed values: [0,1] Default value: 0.7
double-arrows [logical : Read]
When scrolling, always show both arrows. Default value: TRUE
horizontal-offset [integer : Read]
When the menu is a submenu, position it this number of pixels offset horizontally. Default value: -2
horizontal-padding [integer : Read]
Extra space at the left and right edges of the menu. Allowed values: >= 0 Default value: 0
vertical-offset [integer : Read]
When the menu is a submenu, position it this number of pixels offset vertically. Default value: 0
vertical-padding [integer : Read]
Extra space at the top and bottom of the menu. Allowed values: >= 0 Default value: 1


  • GtkMenu
  • gtkMenu
  • GtkMenuPositionFunc
  • GtkMenuDetachFunc
Documentation reproduced from package RGtk2, version 2.20.31, License: GPL

Community examples

Looks like there are no examples yet.