Menu
open class Menu : MenuShell, MenuProtocol
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 GtkComboBox.
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
gtk_menu_popup() 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.
(C Language Example):
// connect our handler which will popup the menu
g_signal_connect_swapped (window, "button_press_event",
G_CALLBACK (my_popup_handler), menu);
Signal handler which displays a popup menu.
(C Language Example):
static gint
my_popup_handler (GtkWidget *widget, GdkEvent *event)
{
GtkMenu *menu;
GdkEventButton *event_button;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
// The "widget" is the menu that was supplied when
// g_signal_connect_swapped() was called.
menu = GTK_MENU (widget);
if (event->type == GDK_BUTTON_PRESS)
{
event_button = (GdkEventButton *) event;
if (event_button->button == GDK_BUTTON_SECONDARY)
{
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
event_button->button, event_button->time);
return TRUE;
}
}
return FALSE;
}
CSS nodes
(plain Language Example):
menu
├── arrow.top
├── <child>
┊
├── <child>
╰── arrow.bottom
The main CSS node of GtkMenu has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes.
The Menu type acts as a reference-counted owner of an underlying GtkMenu instance.
It provides the methods that can operate on this data type through MenuProtocol conformance.
Use Menu as a strong reference or owner of a GtkMenu instance.
-
Designated initialiser from the underlying `C` data type.This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
Menuinstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkMenu>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkMenu>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkMenu>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkMenu>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGtkMenu. i.e., ownership is transferred to theMenuinstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkMenu>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
MenuProtocolWill retainGtkMenu.Declaration
Swift
@inlinable public init<T>(menu other: T) where T : MenuProtocolParameters
otheran instance of a related type that implements
MenuProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
MenuProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Creates a new
GtkMenuDeclaration
Swift
@inlinable public init() -
Creates a
GtkMenuand populates it with menu items and submenus according tomodel.The created menu items are connected to actions found in the
GtkApplicationWindowto which the menu belongs - typically by means of being attached to a widget (seegtk_menu_attach_to_widget()) that is contained within theGtkApplicationWindowswidget hierarchy.Actions can also be added using
gtk_widget_insert_action_group()on the menu’s attach widget or on any of its parent widgets.Declaration
Swift
@inlinable public init<MenuModelT>(model: MenuModelT) where MenuModelT : MenuModelProtocol -
Creates a
GtkMenuand populates it with menu items and submenus according tomodel.The created menu items are connected to actions found in the
GtkApplicationWindowto which the menu belongs - typically by means of being attached to a widget (seegtk_menu_attach_to_widget()) that is contained within theGtkApplicationWindowswidget hierarchy.Actions can also be added using
gtk_widget_insert_action_group()on the menu’s attach widget or on any of its parent widgets.Declaration
Swift
@inlinable public static func newFrom<MenuModelT>(model: MenuModelT) -> Widget! where MenuModelT : MenuModelProtocol
View on GitHub
Install in Dash
Menu Class Reference