MenuButtonRef
public struct MenuButtonRef : MenuButtonProtocol, GWeakCapturing
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 MenuButtonRef
type acts as a lightweight Swift reference to an underlying GtkMenuButton
instance.
It exposes methods that can operate on this data type through MenuButtonProtocol
conformance.
Use MenuButtonRef
only as an unowned
reference to an existing GtkMenuButton
instance.
-
Untyped pointer to the underlying `GtkMenuButton` instance.
For type-safe access, use the generated, typed pointer
menu_button_ptr
property instead.Declaration
Swift
public let ptr: UnsafeMutableRawPointer!
-
Designated initialiser from the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafeMutablePointer<GtkMenuButton>)
-
Designated initialiser from a constant pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init(_ p: UnsafePointer<GtkMenuButton>)
-
Conditional initialiser from an optional pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafeMutablePointer<GtkMenuButton>?)
-
Conditional initialiser from an optional, non-mutable pointer to the underlying
C
data typeDeclaration
Swift
@inlinable init!(_ maybePointer: UnsafePointer<GtkMenuButton>?)
-
Conditional initialiser from an optional
gpointer
Declaration
Swift
@inlinable init!(gpointer g: gpointer?)
-
Conditional initialiser from an optional, non-mutable
gconstpointer
Declaration
Swift
@inlinable init!(gconstpointer g: gconstpointer?)
-
Reference intialiser for a related type that implements
MenuButtonProtocol
Declaration
Swift
@inlinable init<T>(_ other: T) where T : MenuButtonProtocol
-
This factory is syntactic sugar for setting weak pointers wrapped in
GWeak<T>
Declaration
Swift
@inlinable static func unowned<T>(_ other: T) -> MenuButtonRef where T : MenuButtonProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuButtonProtocol
.Declaration
Swift
@inlinable init<T>(cPointer: UnsafeMutablePointer<T>)
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuButtonProtocol
.Declaration
Swift
@inlinable init<T>(constPointer: UnsafePointer<T>)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuButtonProtocol
.Declaration
Swift
@inlinable init(mutating raw: UnsafeRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuButtonProtocol
.Declaration
Swift
@inlinable init(raw: UnsafeMutableRawPointer)
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuButtonProtocol
.Declaration
Swift
@inlinable init(opaquePointer: OpaquePointer)
-
Creates a new `GtkMenuButton` widget with downwards-pointing
arrow as the only child. You can replace the child widget with another
GtkWidget
should you wish to.Declaration
Swift
@inlinable init()