MenuButtonProtocol
public protocol MenuButtonProtocol : ToggleButtonProtocol
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_ARROW_DOWN and the horizontal alignment is GTK_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.
The MenuButtonProtocol protocol exposes the methods and properties of an underlying GtkMenuButton instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see MenuButton.
Alternatively, use MenuButtonRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkMenuButtoninstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
menu_button_ptrDefault implementationTyped pointer to the underlying
GtkMenuButtoninstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMenuButtoninstance.Declaration
Swift
var menu_button_ptr: UnsafeMutablePointer<GtkMenuButton>! { get } -
Required Initialiser for types conforming to
MenuButtonProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MenuButtonPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: MenuButtonPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a MenuButton property
Declaration
Swift
@inlinable func get(property: MenuButtonPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a MenuButton property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: MenuButtonPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
getAlignWidget()Extension methodReturns the parent
GtkWidgetto use to line up with menu.Declaration
Swift
@inlinable func getAlignWidget() -> WidgetRef! -
getDirection()Extension methodReturns the direction the popup will be pointing at when popped up.
Declaration
Swift
@inlinable func getDirection() -> GtkArrowType -
getMenuModel()Extension methodReturns the
GMenuModelused to generate the popup.Declaration
Swift
@inlinable func getMenuModel() -> GIO.MenuModelRef! -
getPopover()Extension methodReturns the
GtkPopoverthat pops out of the button. If the button is not using aGtkPopover, this function returnsnil.Declaration
Swift
@inlinable func getPopover() -> PopoverRef! -
getPopup()Extension methodReturns the
GtkMenuthat pops out of the button. If the button does not use aGtkMenu, this function returnsnil.Declaration
Swift
@inlinable func getPopup() -> MenuRef! -
getUsePopover()Extension methodReturns whether a
GtkPopoveror aGtkMenuwill be constructed from the menu model.Declaration
Swift
@inlinable func getUsePopover() -> Bool -
set(alignWidget:Extension method) Sets the
GtkWidgetto use to line the menu with when popped up. Note that thealign_widgetmust contain theGtkMenuButtonitself.Setting it to
nilmeans that the menu will be aligned with the button itself.Note that this property is only used with menus currently, and not for popovers.
Declaration
Swift
@inlinable func set(alignWidget: WidgetRef? = nil) -
set(alignWidget:Extension method) Sets the
GtkWidgetto use to line the menu with when popped up. Note that thealign_widgetmust contain theGtkMenuButtonitself.Setting it to
nilmeans that the menu will be aligned with the button itself.Note that this property is only used with menus currently, and not for popovers.
Declaration
Swift
@inlinable func set<WidgetT>(alignWidget: WidgetT?) where WidgetT : WidgetProtocol -
set(direction:Extension method) Sets 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.
If the does not fit in the available space in the given direction, GTK+ will its best to keep it inside the screen and fully visible.
If you pass
GTK_ARROW_NONEfor adirection, the popup will behave as if you passedGTK_ARROW_DOWN(although you won’t see any arrows).Declaration
Swift
@inlinable func set(direction: GtkArrowType) -
set(menuModel:Extension method) Sets the
GMenuModelfrom which the popup will be constructed, ornilto dissociate any existing menu model and disable the button.Depending on the value of
GtkMenuButton:use-popover, either aGtkMenuwill be created withgtk_menu_new_from_model(), or aGtkPopoverwithgtk_popover_new_from_model(). In either case, actions will be connected as documented for these functions.If
GtkMenuButton:popuporGtkMenuButton:popoverare already set, those widgets are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func set(menuModel: GIO.MenuModelRef? = nil) -
set(menuModel:Extension method) Sets the
GMenuModelfrom which the popup will be constructed, ornilto dissociate any existing menu model and disable the button.Depending on the value of
GtkMenuButton:use-popover, either aGtkMenuwill be created withgtk_menu_new_from_model(), or aGtkPopoverwithgtk_popover_new_from_model(). In either case, actions will be connected as documented for these functions.If
GtkMenuButton:popuporGtkMenuButton:popoverare already set, those widgets are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func set<MenuModelT>(menuModel: MenuModelT?) where MenuModelT : MenuModelProtocol -
set(popover:Extension method) Sets the
GtkPopoverthat will be popped up when themenu_buttonis clicked, ornilto dissociate any existing popover and disable the button.If
GtkMenuButton:menu-modelorGtkMenuButton:popupare set, those objects are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func set(popover: WidgetRef? = nil) -
set(popover:Extension method) Sets the
GtkPopoverthat will be popped up when themenu_buttonis clicked, ornilto dissociate any existing popover and disable the button.If
GtkMenuButton:menu-modelorGtkMenuButton:popupare set, those objects are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func set<WidgetT>(popover: WidgetT?) where WidgetT : WidgetProtocol -
setPopup(menu:Extension method) Sets the
GtkMenuthat will be popped up when themenu_buttonis clicked, ornilto dissociate any existing menu and disable the button.If
GtkMenuButton:menu-modelorGtkMenuButton:popoverare set, those objects are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func setPopup(menu: WidgetRef? = nil) -
setPopup(menu:Extension method) Sets the
GtkMenuthat will be popped up when themenu_buttonis clicked, ornilto dissociate any existing menu and disable the button.If
GtkMenuButton:menu-modelorGtkMenuButton:popoverare set, those objects are dissociated from themenu_button, and those properties are set tonil.Declaration
Swift
@inlinable func setPopup<WidgetT>(menu: WidgetT?) where WidgetT : WidgetProtocol -
set(usePopover:Extension method) Sets whether to construct a
GtkPopoverinstead ofGtkMenuwhengtk_menu_button_set_menu_model()is called. Note that this property is only consulted when a new menu model is set.Declaration
Swift
@inlinable func set(usePopover: Bool) -
alignWidgetExtension methodReturns the parent
GtkWidgetto use to line up with menu.Declaration
Swift
@inlinable var alignWidget: WidgetRef! { get nonmutating set } -
directionExtension methodThe
GtkArrowTyperepresenting the direction in which the menu or popover will be popped out.Declaration
Swift
@inlinable var direction: GtkArrowType { get nonmutating set } -
menuModelExtension methodReturns the
GMenuModelused to generate the popup.Declaration
Swift
@inlinable var menuModel: GIO.MenuModelRef! { get nonmutating set } -
popoverExtension methodThe
GtkPopoverthat will be popped up when the button is clicked.Declaration
Swift
@inlinable var popover: PopoverRef! { get nonmutating set } -
popupExtension methodThe
GtkMenuthat will be popped up when the button is clicked.Declaration
Swift
@inlinable var popup: MenuRef! { get nonmutating set } -
usePopoverExtension methodReturns whether a
GtkPopoveror aGtkMenuwill be constructed from the menu model.Declaration
Swift
@inlinable var usePopover: Bool { get nonmutating set } -
parentExtension methodUndocumented
Declaration
Swift
@inlinable var parent: GtkToggleButton { get }
View on GitHub
Install in Dash
MenuButtonProtocol Protocol Reference