gtk.menu_button
Module for [MenuButton] class
Types 3
The #GtkMenuButton widget is used to display a popup when clicked on. This popup can be provided either as a #GtkMenu, a #GtkPopover or an abstract #GMenuModel.
The #GtkMenuButton widget can hold any valid child widget. That is, it can hold almost any other standard #GtkWidget. The most commonly used child is #GtkImage. If no widget is explicitely added to the #GtkMenuButton, a #GtkImage is automatically created, using an arrow image oriented according to #GtkMenuButton:direction or the generic “open-menu-symbolic” icon if the direction is not set.
The positioning of the popup is determined by the #GtkMenuButton:direction property of the menu button.
For menus, the #GtkWidget:halign and #GtkWidget:valign properties of the menu are also taken into account. For example, when the direction is gtk.types.ArrowType.Down and the horizontal alignment is gtk.types.Align.Start, the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is “pushed in”.
Direction = Down
- halign = start

- halign = center

- halign = end

Direction = Up
- halign = start

- halign = center

- halign = end

Direction = Left
- valign = start

- valign = center

- valign = end

Direction = Right
- valign = start

- valign = center

- valign = end

CSS nodes
GtkMenuButton has a single CSS node with name button. To differentiate it from a plain #GtkButton, it gets the .popup style class.
MenuButtonGidBuilder builder() static nothrowGet builder for [gtk.menu_button.MenuButton] Returns: New builder objectgtk.container.Container alignWidget() @property nothrowGet `alignWidget` property. Returns: The #GtkWidget to use to align the menu with.void alignWidget(gtk.container.Container propval) @property nothrowSet `alignWidget` property. Params: propval = The #GtkWidget to use to align the menu with.gtk.types.ArrowType direction() @property nothrowGet `direction` property. Returns: The #GtkArrowType representing the direction in which the menu or popover will be popped out.void direction(gtk.types.ArrowType propval) @property nothrowSet `direction` property. Params: propval = The #GtkArrowType representing the direction in which the menu or popover will be popped out.gio.menu_model.MenuModel menuModel() @property nothrowGet `menuModel` property. Returns: The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.void menuModel(gio.menu_model.MenuModel propval) @property nothrowSet `menuModel` property. Params: propval = The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.gtk.popover.Popover popover() @property nothrowGet `popover` property. Returns: The #GtkPopover that will be popped up when the button is clicked.void popover(gtk.popover.Popover propval) @property nothrowSet `popover` property. Params: propval = The #GtkPopover that will be popped up when the button is clicked.gtk.menu.Menu popup() @property nothrowGet `popup` property. Returns: The #GtkMenu that will be popped up when the button is clicked.void popup(gtk.menu.Menu propval) @property nothrowSet `popup` property. Params: propval = The #GtkMenu that will be popped up when the button is clicked.bool usePopover() @property nothrowGet `usePopover` property. Returns: Whether to construct a #GtkPopover from the menu model, or a #GtkMenu.void usePopover(bool propval) @property nothrowSet `usePopover` property. Params: propval = Whether to construct a #GtkPopover from the menu model, or a #GtkMenu.gtk.widget.Widget getAlignWidget() nothrowReturns the parent #GtkWidget to use to line up with menu. Returns: a #GtkWidget value or nullgtk.types.ArrowType getDirection() nothrowReturns the direction the popup will be pointing at when popped up. Returns: a #GtkArrowType valuegio.menu_model.MenuModel getMenuModel() nothrowReturns the #GMenuModel used to generate the popup. Returns: a #GMenuModel or nullgtk.popover.Popover getPopover() nothrowReturns the #GtkPopover that pops out of the button. If the button is not using a #GtkPopover, this function returns null. Returns: a #GtkPopover or nullgtk.menu.Menu getPopup() nothrowReturns the #GtkMenu that pops out of the button. If the button does not use a #GtkMenu, this function returns null. Returns: a #GtkMenu or nullbool getUsePopover() nothrowReturns whether a #GtkPopover or a #GtkMenu will be constructed from the menu model. Returns: true if using a #GtkPopovervoid setAlignWidget(gtk.widget.Widget alignWidget = null) nothrowSets the #GtkWidget to use to line the menu with when popped up. Note that the align_widget must contain the #GtkMenuButton itself.void setDirection(gtk.types.ArrowType direction) nothrowSets the direction in which the popup will be popped up, as well as changing the arrow’s direction. The child will not be changed to an arrow if it was customized.void setMenuModel(gio.menu_model.MenuModel menuModel = null) nothrowSets the #GMenuModel from which the popup will be constructed, or null to dissociate any existing menu model and disable the button.void setPopover(gtk.widget.Widget popover = null) nothrowSets the #GtkPopover that will be popped up when the menu_button is clicked, or null to dissociate any existing popover and disable the button.void setPopup(gtk.widget.Widget menu = null) nothrowSets the #GtkMenu that will be popped up when the menu_button is clicked, or null to dissociate any existing menu and disable the button.void setUsePopover(bool usePopover) nothrowSets whether to construct a #GtkPopover instead of #GtkMenu when [gtk.menu_button.MenuButton.setMenuModel] is called. Note that this property is only consulted when a new menu model is set.Fluent builder implementation template for gtk.menu_button.MenuButton
T alignWidget(gtk.container.Container propval) nothrowSet `alignWidget` property. Params: propval = The #GtkWidget to use to align the menu with. Returns: Builder instance for fluent chainingT direction(gtk.types.ArrowType propval) nothrowSet `direction` property. Params: propval = The #GtkArrowType representing the direction in which the menu or popover will be popped out. Returns: Builder instance for fluent chainingT menuModel(gio.menu_model.MenuModel propval) nothrowSet `menuModel` property. Params: propval = The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.T popover(gtk.popover.Popover propval) nothrowSet `popover` property. Params: propval = The #GtkPopover that will be popped up when the button is clicked. Returns: Builder instance for fluent chainingT popup(gtk.menu.Menu propval) nothrowSet `popup` property. Params: propval = The #GtkMenu that will be popped up when the button is clicked. Returns: Builder instance for fluent chainingT usePopover(bool propval) nothrowSet `usePopover` property. Params: propval = Whether to construct a #GtkPopover from the menu model, or a #GtkMenu. Returns: Builder instance for fluent chainingFluent builder for gtk.menu_button.MenuButton