Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- attach
- attachToWidget
- detach
- getAccelGroup
- getAccelPath
- getActive
- getAttachWidget
- getForAttachWidget
- getMonitor
- getReserveToggleSize
- getTearoffState
- getTitle
- new
- newFromModel
- placeOnMonitor
- popdown
- popup
- popupAtPointer
- popupAtRect
- popupAtWidget
- popupForDevice
- reorderChild
- reposition
- setAccelGroup
- setAccelPath
- setActive
- setMonitor
- setReserveToggleSize
- setScreen
- setTearoffState
- setTitle
- Properties
- Signals
A Menu
is a MenuShell
that implements a drop down menu
consisting of a list of MenuItem
objects which can be navigated
and activated by the user to perform application functions.
A Menu
is most commonly dropped down by activating a
MenuItem
in a MenuBar
or popped up by activating a
MenuItem
in another Menu
.
A Menu
can also be popped up by activating a ComboBox
.
Other composite widgets such as the Notebook
can pop up a
Menu
as well.
Applications can display a Menu
as a popup menu by calling the
menuPopup
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 code
// 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 code
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 code
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.
- newtype Menu = Menu (ManagedPtr Menu)
- class GObject o => IsMenu o
- toMenu :: IsMenu o => o -> IO Menu
- noMenu :: Maybe Menu
- data MenuAttachMethodInfo
- menuAttach :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Word32 -> Word32 -> Word32 -> Word32 -> m ()
- data MenuAttachToWidgetMethodInfo
- menuAttachToWidget :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Maybe MenuDetachFunc -> m ()
- data MenuDetachMethodInfo
- menuDetach :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- data MenuGetAccelGroupMethodInfo
- menuGetAccelGroup :: (HasCallStack, MonadIO m, IsMenu a) => a -> m AccelGroup
- data MenuGetAccelPathMethodInfo
- menuGetAccelPath :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Text
- data MenuGetActiveMethodInfo
- menuGetActive :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Widget
- data MenuGetAttachWidgetMethodInfo
- menuGetAttachWidget :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Widget
- menuGetForAttachWidget :: (HasCallStack, MonadIO m, IsWidget a) => a -> m [Widget]
- data MenuGetMonitorMethodInfo
- menuGetMonitor :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Int32
- data MenuGetReserveToggleSizeMethodInfo
- menuGetReserveToggleSize :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Bool
- data MenuGetTearoffStateMethodInfo
- menuGetTearoffState :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Bool
- data MenuGetTitleMethodInfo
- menuGetTitle :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Text
- menuNew :: (HasCallStack, MonadIO m) => m Menu
- menuNewFromModel :: (HasCallStack, MonadIO m, IsMenuModel a) => a -> m Menu
- data MenuPlaceOnMonitorMethodInfo
- menuPlaceOnMonitor :: (HasCallStack, MonadIO m, IsMenu a, IsMonitor b) => a -> b -> m ()
- data MenuPopdownMethodInfo
- menuPopdown :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- data MenuPopupMethodInfo
- menuPopup :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b, IsWidget c) => a -> Maybe b -> Maybe c -> Maybe MenuPositionFunc -> Word32 -> Word32 -> m ()
- data MenuPopupAtPointerMethodInfo
- menuPopupAtPointer :: (HasCallStack, MonadIO m, IsMenu a) => a -> Maybe Event -> m ()
- data MenuPopupAtRectMethodInfo
- menuPopupAtRect :: (HasCallStack, MonadIO m, IsMenu a, IsWindow b) => a -> b -> Rectangle -> Gravity -> Gravity -> Maybe Event -> m ()
- data MenuPopupAtWidgetMethodInfo
- menuPopupAtWidget :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Gravity -> Gravity -> Maybe Event -> m ()
- data MenuPopupForDeviceMethodInfo
- menuPopupForDevice :: (HasCallStack, MonadIO m, IsMenu a, IsDevice b, IsWidget c, IsWidget d) => a -> Maybe b -> Maybe c -> Maybe d -> Maybe MenuPositionFunc -> Word32 -> Word32 -> m ()
- data MenuReorderChildMethodInfo
- menuReorderChild :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Int32 -> m ()
- data MenuRepositionMethodInfo
- menuReposition :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- data MenuSetAccelGroupMethodInfo
- menuSetAccelGroup :: (HasCallStack, MonadIO m, IsMenu a, IsAccelGroup b) => a -> Maybe b -> m ()
- data MenuSetAccelPathMethodInfo
- menuSetAccelPath :: (HasCallStack, MonadIO m, IsMenu a) => a -> Maybe Text -> m ()
- data MenuSetActiveMethodInfo
- menuSetActive :: (HasCallStack, MonadIO m, IsMenu a) => a -> Word32 -> m ()
- data MenuSetMonitorMethodInfo
- menuSetMonitor :: (HasCallStack, MonadIO m, IsMenu a) => a -> Int32 -> m ()
- data MenuSetReserveToggleSizeMethodInfo
- menuSetReserveToggleSize :: (HasCallStack, MonadIO m, IsMenu a) => a -> Bool -> m ()
- data MenuSetScreenMethodInfo
- menuSetScreen :: (HasCallStack, MonadIO m, IsMenu a, IsScreen b) => a -> Maybe b -> m ()
- data MenuSetTearoffStateMethodInfo
- menuSetTearoffState :: (HasCallStack, MonadIO m, IsMenu a) => a -> Bool -> m ()
- data MenuSetTitleMethodInfo
- menuSetTitle :: (HasCallStack, MonadIO m, IsMenu a) => a -> Text -> m ()
- data MenuAccelGroupPropertyInfo
- clearMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAccelGroup :: (IsMenu o, IsAccelGroup a) => a -> IO (GValueConstruct o)
- getMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m AccelGroup
- menuAccelGroup :: AttrLabelProxy "accelGroup"
- setMenuAccelGroup :: (MonadIO m, IsMenu o, IsAccelGroup a) => o -> a -> m ()
- data MenuAccelPathPropertyInfo
- clearMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAccelPath :: IsMenu o => Text -> IO (GValueConstruct o)
- getMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m Text
- menuAccelPath :: AttrLabelProxy "accelPath"
- setMenuAccelPath :: (MonadIO m, IsMenu o) => o -> Text -> m ()
- data MenuActivePropertyInfo
- constructMenuActive :: IsMenu o => Int32 -> IO (GValueConstruct o)
- getMenuActive :: (MonadIO m, IsMenu o) => o -> m Int32
- menuActive :: AttrLabelProxy "active"
- setMenuActive :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- data MenuAnchorHintsPropertyInfo
- constructMenuAnchorHints :: IsMenu o => [AnchorHints] -> IO (GValueConstruct o)
- getMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> m [AnchorHints]
- menuAnchorHints :: AttrLabelProxy "anchorHints"
- setMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> [AnchorHints] -> m ()
- data MenuAttachWidgetPropertyInfo
- clearMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAttachWidget :: (IsMenu o, IsWidget a) => a -> IO (GValueConstruct o)
- getMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m Widget
- menuAttachWidget :: AttrLabelProxy "attachWidget"
- setMenuAttachWidget :: (MonadIO m, IsMenu o, IsWidget a) => o -> a -> m ()
- data MenuMenuTypeHintPropertyInfo
- constructMenuMenuTypeHint :: IsMenu o => WindowTypeHint -> IO (GValueConstruct o)
- getMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> m WindowTypeHint
- menuMenuTypeHint :: AttrLabelProxy "menuTypeHint"
- setMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> WindowTypeHint -> m ()
- data MenuMonitorPropertyInfo
- constructMenuMonitor :: IsMenu o => Int32 -> IO (GValueConstruct o)
- getMenuMonitor :: (MonadIO m, IsMenu o) => o -> m Int32
- menuMonitor :: AttrLabelProxy "monitor"
- setMenuMonitor :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- data MenuRectAnchorDxPropertyInfo
- constructMenuRectAnchorDx :: IsMenu o => Int32 -> IO (GValueConstruct o)
- getMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> m Int32
- menuRectAnchorDx :: AttrLabelProxy "rectAnchorDx"
- setMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- data MenuRectAnchorDyPropertyInfo
- constructMenuRectAnchorDy :: IsMenu o => Int32 -> IO (GValueConstruct o)
- getMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> m Int32
- menuRectAnchorDy :: AttrLabelProxy "rectAnchorDy"
- setMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- data MenuReserveToggleSizePropertyInfo
- constructMenuReserveToggleSize :: IsMenu o => Bool -> IO (GValueConstruct o)
- getMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> m Bool
- menuReserveToggleSize :: AttrLabelProxy "reserveToggleSize"
- setMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> Bool -> m ()
- data MenuTearoffStatePropertyInfo
- constructMenuTearoffState :: IsMenu o => Bool -> IO (GValueConstruct o)
- getMenuTearoffState :: (MonadIO m, IsMenu o) => o -> m Bool
- menuTearoffState :: AttrLabelProxy "tearoffState"
- setMenuTearoffState :: (MonadIO m, IsMenu o) => o -> Bool -> m ()
- data MenuTearoffTitlePropertyInfo
- clearMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuTearoffTitle :: IsMenu o => Text -> IO (GValueConstruct o)
- getMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m (Maybe Text)
- menuTearoffTitle :: AttrLabelProxy "tearoffTitle"
- setMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> Text -> m ()
- type C_MenuMoveScrollCallback = Ptr () -> CUInt -> Ptr () -> IO ()
- type MenuMoveScrollCallback = ScrollType -> IO ()
- data MenuMoveScrollSignalInfo
- afterMenuMoveScroll :: (GObject a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId
- genClosure_MenuMoveScroll :: MenuMoveScrollCallback -> IO Closure
- mk_MenuMoveScrollCallback :: C_MenuMoveScrollCallback -> IO (FunPtr C_MenuMoveScrollCallback)
- noMenuMoveScrollCallback :: Maybe MenuMoveScrollCallback
- onMenuMoveScroll :: (GObject a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId
- wrap_MenuMoveScrollCallback :: MenuMoveScrollCallback -> Ptr () -> CUInt -> Ptr () -> IO ()
- type C_MenuPoppedUpCallback = Ptr () -> Ptr () -> Ptr () -> CInt -> CInt -> Ptr () -> IO ()
- type MenuPoppedUpCallback = Ptr () -> Ptr () -> Bool -> Bool -> IO ()
- data MenuPoppedUpSignalInfo
- afterMenuPoppedUp :: (GObject a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId
- genClosure_MenuPoppedUp :: MenuPoppedUpCallback -> IO Closure
- mk_MenuPoppedUpCallback :: C_MenuPoppedUpCallback -> IO (FunPtr C_MenuPoppedUpCallback)
- noMenuPoppedUpCallback :: Maybe MenuPoppedUpCallback
- onMenuPoppedUp :: (GObject a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId
- wrap_MenuPoppedUpCallback :: MenuPoppedUpCallback -> Ptr () -> Ptr () -> Ptr () -> CInt -> CInt -> Ptr () -> IO ()
Exported types
GObject Menu Source # | |
IsImplementorIface Menu Source # | |
IsObject Menu Source # | |
IsWidget Menu Source # | |
IsMenuShell Menu Source # | |
IsMenu Menu Source # | |
IsContainer Menu Source # | |
IsBuildable Menu Source # | |
((~) * info (ResolveMenuMethod t Menu), MethodInfo * info Menu p) => IsLabel t (Menu -> p) Source # | |
((~) * info (ResolveMenuMethod t Menu), MethodInfo * info Menu p) => IsLabelProxy t (Menu -> p) Source # | |
HasAttributeList * Menu Source # | |
type AttributeList Menu Source # | |
type SignalList Menu Source # | |
class GObject o => IsMenu o Source #
(GObject a, UnknownAncestorError Constraint Menu a) => IsMenu a Source # | |
IsMenu Menu Source # | |
IsMenu RecentChooserMenu Source # | |
Methods
attach
data MenuAttachMethodInfo Source #
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Word32 |
|
-> Word32 |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Adds a new MenuItem
to a (table) menu. The number of “cells” that
an item will occupy is specified by leftAttach
, rightAttach
,
topAttach
and bottomAttach
. These each represent the leftmost,
rightmost, uppermost and lower column and row numbers of the table.
(Columns and rows are indexed from zero).
Note that this function is not related to menuDetach
.
Since: 2.4
attachToWidget
data MenuAttachToWidgetMethodInfo Source #
((~) * signature (b -> Maybe MenuDetachFunc -> m ()), MonadIO m, IsMenu a, IsWidget b) => MethodInfo * MenuAttachToWidgetMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Maybe MenuDetachFunc |
|
-> m () |
Attaches the menu to the widget and provides a callback function
that will be invoked when the menu calls menuDetach
during
its destruction.
If the menu is attached to the widget then it will be destroyed when the widget is destroyed, as if it was a child widget. An attached menu will also move between screens correctly if the widgets moves between screens.
detach
data MenuDetachMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsMenu a) => MethodInfo * MenuDetachMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Detaches the menu from the widget to which it had been attached.
This function will call the callback function, detacher
, provided
when the menuAttachToWidget
function was called.
getAccelGroup
data MenuGetAccelGroupMethodInfo Source #
((~) * signature (m AccelGroup), MonadIO m, IsMenu a) => MethodInfo * MenuGetAccelGroupMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m AccelGroup | Returns: the |
Gets the AccelGroup
which holds global accelerators for the
menu. See menuSetAccelGroup
.
getAccelPath
data MenuGetAccelPathMethodInfo Source #
((~) * signature (m Text), MonadIO m, IsMenu a) => MethodInfo * MenuGetAccelPathMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Text | Returns: the accelerator path set on the menu. |
Retrieves the accelerator path set on the menu.
Since: 2.14
getActive
data MenuGetActiveMethodInfo Source #
((~) * signature (m Widget), MonadIO m, IsMenu a) => MethodInfo * MenuGetActiveMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Widget | Returns: the |
Returns the selected menu item from the menu. This is used by the
ComboBox
.
getAttachWidget
data MenuGetAttachWidgetMethodInfo Source #
((~) * signature (m Widget), MonadIO m, IsMenu a) => MethodInfo * MenuGetAttachWidgetMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Widget | Returns: the |
Returns the Widget
that the menu is attached to.
getForAttachWidget
menuGetForAttachWidget Source #
:: (HasCallStack, MonadIO m, IsWidget a) | |
=> a |
|
-> m [Widget] | Returns: the list of menus attached to his widget. |
Returns a list of the menus which are attached to this widget. This list is owned by GTK+ and must not be modified.
Since: 2.6
getMonitor
data MenuGetMonitorMethodInfo Source #
((~) * signature (m Int32), MonadIO m, IsMenu a) => MethodInfo * MenuGetMonitorMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Int32 | Returns: the number of the monitor on which the menu should be popped up or -1, if no monitor has been set |
Retrieves the number of the monitor on which to show the menu.
Since: 2.14
getReserveToggleSize
data MenuGetReserveToggleSizeMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsMenu a) => MethodInfo * MenuGetReserveToggleSizeMethodInfo a signature Source # | |
menuGetReserveToggleSize Source #
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Bool | Returns: Whether the menu reserves toggle space |
Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Since: 2.18
getTearoffState
data MenuGetTearoffStateMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsMenu a) => MethodInfo * MenuGetTearoffStateMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Bool | Returns: |
Deprecated: (Since version 3.10)
Returns whether the menu is torn off.
See menuSetTearoffState
.
getTitle
data MenuGetTitleMethodInfo Source #
((~) * signature (m Text), MonadIO m, IsMenu a) => MethodInfo * MenuGetTitleMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Text | Returns: the title of the menu, or |
Deprecated: (Since version 3.10)
Returns the title of the menu. See menuSetTitle
.
new
newFromModel
:: (HasCallStack, MonadIO m, IsMenuModel a) | |
=> a |
|
-> m Menu | Returns: a new |
Creates a Menu
and populates it with menu items and
submenus according to model
.
The created menu items are connected to actions found in the
ApplicationWindow
to which the menu belongs - typically
by means of being attached to a widget (see menuAttachToWidget
)
that is contained within the GtkApplicationWindows
widget hierarchy.
Actions can also be added using widgetInsertActionGroup
on the menu's
attach widget or on any of its parent widgets.
Since: 3.4
placeOnMonitor
data MenuPlaceOnMonitorMethodInfo Source #
((~) * signature (b -> m ()), MonadIO m, IsMenu a, IsMonitor b) => MethodInfo * MenuPlaceOnMonitorMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a, IsMonitor b) | |
=> a |
|
-> b |
|
-> m () |
Places menu
on the given monitor.
Since: 3.22
popdown
data MenuPopdownMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsMenu a) => MethodInfo * MenuPopdownMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Removes the menu from the screen.
popup
data MenuPopupMethodInfo Source #
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b, IsWidget c) | |
=> a |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe MenuPositionFunc |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Deprecated: (Since version 3.22)Please use menuPopupAtWidget
, menuPopupAtPointer
. or menuPopupAtRect
instead
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive
menus, and will typically supply Nothing
for the parentMenuShell
,
parentMenuItem
, func
and data
parameters. The default menu
positioning function will position the menu at the current mouse
cursor position.
The button
parameter should be the mouse button pressed to initiate
the menu popup. If the menu popup was initiated by something other
than a mouse button press, such as a mouse button release or a keypress,
button
should be 0.
The activateTime
parameter is used to conflict-resolve initiation
of concurrent requests for mouse/keyboard grab requests. To function
properly, this needs to be the timestamp of the user event (such as
a mouse click or key press) that caused the initiation of the popup.
Only if no such event is available, getCurrentEventTime
can
be used instead.
Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
popupAtPointer
data MenuPopupAtPointerMethodInfo Source #
((~) * signature (Maybe Event -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuPopupAtPointerMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Maybe Event |
|
-> m () |
Displays menu
and makes it available for selection.
See gtk_menu_popup_at_widget () to pop up a menu at a widget. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
menu
will be positioned at the pointer associated with triggerEvent
.
Properties that influence the behaviour of this function are
Menu
:anchor-hints
, Menu
:rect-anchor-dx
, Menu
:rect-anchor-dy
, and
Menu
:menu-type-hint
. Connect to the Menu
::popped-up
signal to find
out how it was actually positioned.
Since: 3.22
popupAtRect
:: (HasCallStack, MonadIO m, IsMenu a, IsWindow b) | |
=> a |
|
-> b |
|
-> Rectangle |
|
-> Gravity |
|
-> Gravity |
|
-> Maybe Event |
|
-> m () |
Displays menu
and makes it available for selection.
See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which handle more common cases for popping up menus.
menu
will be positioned at rect
, aligning their anchor points. rect
is
relative to the top-left corner of rectWindow
. rectAnchor
and
menuAnchor
determine anchor points on rect
and menu
to pin together.
menu
can optionally be offset by Menu
:rect-anchor-dx
and
Menu
:rect-anchor-dy
.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
Menu
:anchor-hints
and Menu
:menu-type-hint
. Connect to the
Menu
::popped-up
signal to find out how it was actually positioned.
Since: 3.22
popupAtWidget
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Gravity |
|
-> Gravity |
|
-> Maybe Event |
|
-> m () |
Displays menu
and makes it available for selection.
See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
menu
will be positioned at widget
, aligning their anchor points.
widgetAnchor
and menuAnchor
determine anchor points on widget
and menu
to pin together. menu
can optionally be offset by Menu
:rect-anchor-dx
and Menu
:rect-anchor-dy
.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
Menu
:anchor-hints
and Menu
:menu-type-hint
. Connect to the
Menu
::popped-up
signal to find out how it was actually positioned.
Since: 3.22
popupForDevice
:: (HasCallStack, MonadIO m, IsMenu a, IsDevice b, IsWidget c, IsWidget d) | |
=> a |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe d |
|
-> Maybe MenuPositionFunc |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Deprecated: (Since version 3.22)Please use menuPopupAtWidget
, menuPopupAtPointer
. or menuPopupAtRect
instead
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus,
and will typically supply Nothing
for the parentMenuShell
,
parentMenuItem
, func
, data
and destroy
parameters. The default
menu positioning function will position the menu at the current position
of device
(or its corresponding pointer).
The button
parameter should be the mouse button pressed to initiate
the menu popup. If the menu popup was initiated by something other than
a mouse button press, such as a mouse button release or a keypress,
button
should be 0.
The activateTime
parameter is used to conflict-resolve initiation of
concurrent requests for mouse/keyboard grab requests. To function
properly, this needs to be the time stamp of the user event (such as
a mouse click or key press) that caused the initiation of the popup.
Only if no such event is available, getCurrentEventTime
can
be used instead.
Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
Since: 3.0
reorderChild
data MenuReorderChildMethodInfo Source #
((~) * signature (b -> Int32 -> m ()), MonadIO m, IsMenu a, IsWidget b) => MethodInfo * MenuReorderChildMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Int32 |
|
-> m () |
Moves child
to a new position
in the list of menu
children.
reposition
data MenuRepositionMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsMenu a) => MethodInfo * MenuRepositionMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Repositions the menu according to its position function.
setAccelGroup
data MenuSetAccelGroupMethodInfo Source #
((~) * signature (Maybe b -> m ()), MonadIO m, IsMenu a, IsAccelGroup b) => MethodInfo * MenuSetAccelGroupMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a, IsAccelGroup b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Set the AccelGroup
which holds global accelerators for the
menu. This accelerator group needs to also be added to all windows
that this menu is being used in with windowAddAccelGroup
,
in order for those windows to support all the accelerators
contained in this group.
setAccelPath
data MenuSetAccelPathMethodInfo Source #
((~) * signature (Maybe Text -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetAccelPathMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets an accelerator path for this menu from which accelerator paths
for its immediate children, its menu items, can be constructed.
The main purpose of this function is to spare the programmer the
inconvenience of having to call menuItemSetAccelPath
on
each menu item that should support runtime user changable accelerators.
Instead, by just calling menuSetAccelPath
on their parent,
each menu item of this menu, that contains a label describing its
purpose, automatically gets an accel path assigned.
For example, a menu containing menu items “New” and “Exit”, will, after
gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");
has been
called, assign its items the accel paths: "<Gnumeric-Sheet>/File/New"
and "<Gnumeric-Sheet>/File/Exit"
.
Assigning accel paths to menu items then enables the user to change
their accelerators at runtime. More details about accelerator paths
and their default setups can be found at accelMapAddEntry
.
Note that accelPath
string will be stored in a GQuark
. Therefore,
if you pass a static string, you can save some memory by interning
it first with internStaticString
.
setActive
data MenuSetActiveMethodInfo Source #
((~) * signature (Word32 -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetActiveMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Word32 |
|
-> m () |
Selects the specified menu item within the menu. This is used by
the ComboBox
and should not be used by anyone else.
setMonitor
data MenuSetMonitorMethodInfo Source #
((~) * signature (Int32 -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetMonitorMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Int32 |
|
-> m () |
Informs GTK+ on which monitor a menu should be popped up.
See monitorGetGeometry
.
This function should be called from a MenuPositionFunc
if the menu should not appear on the same monitor as the pointer.
This information can’t be reliably inferred from the coordinates
returned by a MenuPositionFunc
, since, for very long menus,
these coordinates may extend beyond the monitor boundaries or even
the screen boundaries.
Since: 2.4
setReserveToggleSize
data MenuSetReserveToggleSizeMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetReserveToggleSizeMethodInfo a signature Source # | |
menuSetReserveToggleSize Source #
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the menu should reserve space for drawing toggles or icons, regardless of their actual presence.
Since: 2.18
setScreen
data MenuSetScreenMethodInfo Source #
((~) * signature (Maybe b -> m ()), MonadIO m, IsMenu a, IsScreen b) => MethodInfo * MenuSetScreenMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a, IsScreen b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the Screen
on which the menu will be displayed.
Since: 2.2
setTearoffState
data MenuSetTearoffStateMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetTearoffStateMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Bool |
|
-> m () |
Deprecated: (Since version 3.10)
Changes the tearoff state of the menu. A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.
setTitle
data MenuSetTitleMethodInfo Source #
((~) * signature (Text -> m ()), MonadIO m, IsMenu a) => MethodInfo * MenuSetTitleMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Text |
|
-> m () |
Deprecated: (Since version 3.10)
Sets the title string for the menu.
The title is displayed when the menu is shown as a tearoff
menu. If title
is Nothing
, the menu will see if it is attached
to a parent menu item, and if so it will try to use the same
text as that menu item’s label.
Properties
accelGroup
data MenuAccelGroupPropertyInfo Source #
clearMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m () Source #
constructMenuAccelGroup :: (IsMenu o, IsAccelGroup a) => a -> IO (GValueConstruct o) Source #
getMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m AccelGroup Source #
menuAccelGroup :: AttrLabelProxy "accelGroup" Source #
setMenuAccelGroup :: (MonadIO m, IsMenu o, IsAccelGroup a) => o -> a -> m () Source #
accelPath
data MenuAccelPathPropertyInfo Source #
clearMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m () Source #
constructMenuAccelPath :: IsMenu o => Text -> IO (GValueConstruct o) Source #
menuAccelPath :: AttrLabelProxy "accelPath" Source #
active
data MenuActivePropertyInfo Source #
constructMenuActive :: IsMenu o => Int32 -> IO (GValueConstruct o) Source #
menuActive :: AttrLabelProxy "active" Source #
anchorHints
data MenuAnchorHintsPropertyInfo Source #
constructMenuAnchorHints :: IsMenu o => [AnchorHints] -> IO (GValueConstruct o) Source #
getMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> m [AnchorHints] Source #
menuAnchorHints :: AttrLabelProxy "anchorHints" Source #
setMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> [AnchorHints] -> m () Source #
attachWidget
data MenuAttachWidgetPropertyInfo Source #
clearMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m () Source #
constructMenuAttachWidget :: (IsMenu o, IsWidget a) => a -> IO (GValueConstruct o) Source #
menuAttachWidget :: AttrLabelProxy "attachWidget" Source #
menuTypeHint
data MenuMenuTypeHintPropertyInfo Source #
constructMenuMenuTypeHint :: IsMenu o => WindowTypeHint -> IO (GValueConstruct o) Source #
getMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> m WindowTypeHint Source #
menuMenuTypeHint :: AttrLabelProxy "menuTypeHint" Source #
setMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> WindowTypeHint -> m () Source #
monitor
data MenuMonitorPropertyInfo Source #
constructMenuMonitor :: IsMenu o => Int32 -> IO (GValueConstruct o) Source #
menuMonitor :: AttrLabelProxy "monitor" Source #
rectAnchorDx
data MenuRectAnchorDxPropertyInfo Source #
constructMenuRectAnchorDx :: IsMenu o => Int32 -> IO (GValueConstruct o) Source #
menuRectAnchorDx :: AttrLabelProxy "rectAnchorDx" Source #
rectAnchorDy
data MenuRectAnchorDyPropertyInfo Source #
constructMenuRectAnchorDy :: IsMenu o => Int32 -> IO (GValueConstruct o) Source #
menuRectAnchorDy :: AttrLabelProxy "rectAnchorDy" Source #
reserveToggleSize
data MenuReserveToggleSizePropertyInfo Source #
constructMenuReserveToggleSize :: IsMenu o => Bool -> IO (GValueConstruct o) Source #
menuReserveToggleSize :: AttrLabelProxy "reserveToggleSize" Source #
tearoffState
data MenuTearoffStatePropertyInfo Source #
constructMenuTearoffState :: IsMenu o => Bool -> IO (GValueConstruct o) Source #
menuTearoffState :: AttrLabelProxy "tearoffState" Source #
tearoffTitle
data MenuTearoffTitlePropertyInfo Source #
clearMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m () Source #
constructMenuTearoffTitle :: IsMenu o => Text -> IO (GValueConstruct o) Source #
menuTearoffTitle :: AttrLabelProxy "tearoffTitle" Source #
Signals
moveScroll
type MenuMoveScrollCallback = ScrollType -> IO () Source #
afterMenuMoveScroll :: (GObject a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId Source #
mk_MenuMoveScrollCallback :: C_MenuMoveScrollCallback -> IO (FunPtr C_MenuMoveScrollCallback) Source #
onMenuMoveScroll :: (GObject a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId Source #
wrap_MenuMoveScrollCallback :: MenuMoveScrollCallback -> Ptr () -> CUInt -> Ptr () -> IO () Source #
poppedUp
type C_MenuPoppedUpCallback = Ptr () -> Ptr () -> Ptr () -> CInt -> CInt -> Ptr () -> IO () Source #
afterMenuPoppedUp :: (GObject a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId Source #
onMenuPoppedUp :: (GObject a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId Source #