Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
The MenuButton
widget is used to display a popup when clicked on.
This popup can be provided either as a Menu
, a Popover
or an
abstract MenuModel
.
The MenuButton
widget can hold any valid child widget. That is, it
can hold almost any other standard Widget
. The most commonly used
child is Image
. If no widget is explicitely added to the MenuButton
,
a Image
is automatically created, using an arrow image oriented
according to MenuButton
:direction
or the generic “open-menu-symbolic”
icon if the direction is not set.
The positioning of the popup is determined by the MenuButton
:direction
property of the menu button.
For menus, the Widget
:halign
and Widget
:valign
properties of the
menu are also taken into account. For example, when the direction is
ArrowTypeDown
and the horizontal alignment is AlignStart
, 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 Button
, it gets the .popup style class.
Synopsis
- newtype MenuButton = MenuButton (ManagedPtr MenuButton)
- class (GObject o, IsDescendantOf MenuButton o) => IsMenuButton o
- toMenuButton :: (MonadIO m, IsMenuButton o) => o -> m MenuButton
- noMenuButton :: Maybe MenuButton
- menuButtonGetAlignWidget :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Widget)
- menuButtonGetDirection :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m ArrowType
- menuButtonGetMenuModel :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe MenuModel)
- menuButtonGetPopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Popover)
- menuButtonGetPopup :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Menu)
- menuButtonGetUsePopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m Bool
- menuButtonNew :: (HasCallStack, MonadIO m) => m MenuButton
- menuButtonSetAlignWidget :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetDirection :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> ArrowType -> m ()
- menuButtonSetMenuModel :: (HasCallStack, MonadIO m, IsMenuButton a, IsMenuModel b) => a -> Maybe b -> m ()
- menuButtonSetPopover :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetPopup :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetUsePopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> Bool -> m ()
- clearMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonAlignWidget :: (IsMenuButton o, IsContainer a) => a -> IO (GValueConstruct o)
- getMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Container)
- setMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o, IsContainer a) => o -> a -> m ()
- constructMenuButtonDirection :: IsMenuButton o => ArrowType -> IO (GValueConstruct o)
- getMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> m ArrowType
- setMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> ArrowType -> m ()
- clearMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonMenuModel :: (IsMenuButton o, IsMenuModel a) => a -> IO (GValueConstruct o)
- getMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m (Maybe MenuModel)
- setMenuButtonMenuModel :: (MonadIO m, IsMenuButton o, IsMenuModel a) => o -> a -> m ()
- clearMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonPopover :: (IsMenuButton o, IsPopover a) => a -> IO (GValueConstruct o)
- getMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Popover)
- setMenuButtonPopover :: (MonadIO m, IsMenuButton o, IsPopover a) => o -> a -> m ()
- clearMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonPopup :: (IsMenuButton o, IsMenu a) => a -> IO (GValueConstruct o)
- getMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Menu)
- setMenuButtonPopup :: (MonadIO m, IsMenuButton o, IsMenu a) => o -> a -> m ()
- constructMenuButtonUsePopover :: IsMenuButton o => Bool -> IO (GValueConstruct o)
- getMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> m Bool
- setMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> Bool -> m ()
Exported types
newtype MenuButton Source #
Memory-managed wrapper type.
Instances
Eq MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton (==) :: MenuButton -> MenuButton -> Bool # (/=) :: MenuButton -> MenuButton -> Bool # | |
IsGValue MenuButton Source # | Convert |
Defined in GI.Gtk.Objects.MenuButton toGValue :: MenuButton -> IO GValue # fromGValue :: GValue -> IO MenuButton # | |
GObject MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton gobjectType :: IO GType # | |
HasParentTypes MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton | |
type ParentTypes MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton type ParentTypes MenuButton = '[ToggleButton, Button, Bin, Container, Widget, Object, ImplementorIface, Actionable, Activatable, Buildable] |
class (GObject o, IsDescendantOf MenuButton o) => IsMenuButton o Source #
Type class for types which can be safely cast to MenuButton
, for instance with toMenuButton
.
Instances
(GObject o, IsDescendantOf MenuButton o) => IsMenuButton o Source # | |
Defined in GI.Gtk.Objects.MenuButton |
toMenuButton :: (MonadIO m, IsMenuButton o) => o -> m MenuButton Source #
Cast to MenuButton
, for types for which this is known to be safe. For general casts, use castTo
.
noMenuButton :: Maybe MenuButton Source #
A convenience alias for Nothing
:: Maybe
MenuButton
.
Methods
Overloaded methods
getAlignWidget
menuButtonGetAlignWidget Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Widget) |
Returns the parent Widget
to use to line up with menu.
Since: 3.6
getDirection
menuButtonGetDirection Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m ArrowType | Returns: a |
Returns the direction the popup will be pointing at when popped up.
Since: 3.6
getMenuModel
menuButtonGetMenuModel Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe MenuModel) |
Returns the MenuModel
used to generate the popup.
Since: 3.6
getPopover
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Popover) |
getPopup
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Menu) |
getUsePopover
menuButtonGetUsePopover Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m Bool |
new
:: (HasCallStack, MonadIO m) | |
=> m MenuButton | Returns: The newly created |
Creates a new MenuButton
widget with downwards-pointing
arrow as the only child. You can replace the child widget
with another Widget
should you wish to.
Since: 3.6
setAlignWidget
menuButtonSetAlignWidget Source #
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the Widget
to use to line the menu with when popped up.
Note that the alignWidget
must contain the MenuButton
itself.
Setting it to Nothing
means that the menu will be aligned with the
button itself.
Note that this property is only used with menus currently, and not for popovers.
Since: 3.6
setDirection
menuButtonSetDirection Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> ArrowType |
|
-> m () |
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 ArrowTypeNone
for a direction
, the popup will behave
as if you passed ArrowTypeDown
(although you won’t see any arrows).
Since: 3.6
setMenuModel
menuButtonSetMenuModel Source #
:: (HasCallStack, MonadIO m, IsMenuButton a, IsMenuModel b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the MenuModel
from which the popup will be constructed,
or Nothing
to dissociate any existing menu model and disable the button.
Depending on the value of MenuButton
:use-popover
, either a
Menu
will be created with menuNewFromModel
, or a
Popover
with popoverNewFromModel
. In either case,
actions will be connected as documented for these functions.
If MenuButton
:popup
or MenuButton
:popover
are already set, those
widgets are dissociated from the menuButton
, and those properties are set
to Nothing
.
Since: 3.6
setPopover
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the Popover
that will be popped up when the menuButton
is clicked,
or Nothing
to dissociate any existing popover and disable the button.
If MenuButton
:menu-model
or MenuButton
:popup
are set, those objects
are dissociated from the menuButton
, and those properties are set to Nothing
.
Since: 3.12
setPopup
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b | |
-> m () |
Sets the Menu
that will be popped up when the menuButton
is clicked, or
Nothing
to dissociate any existing menu and disable the button.
If MenuButton
:menu-model
or MenuButton
:popover
are set, those objects
are dissociated from the menuButton
, and those properties are set to Nothing
.
Since: 3.6
setUsePopover
menuButtonSetUsePopover Source #
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether to construct a Popover
instead of Menu
when menuButtonSetMenuModel
is called. Note that
this property is only consulted when a new menu model is set.
Since: 3.12
Properties
alignWidget
The Widget
to use to align the menu with.
Since: 3.6
clearMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m () Source #
Set the value of the “align-widget
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#alignWidget
constructMenuButtonAlignWidget :: (IsMenuButton o, IsContainer a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “align-widget
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Container) Source #
Get the value of the “align-widget
” property.
When overloading is enabled, this is equivalent to
get
menuButton #alignWidget
setMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o, IsContainer a) => o -> a -> m () Source #
Set the value of the “align-widget
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #alignWidget:=
value ]
direction
The ArrowType
representing the direction in which the
menu or popover will be popped out.
Since: 3.6
constructMenuButtonDirection :: IsMenuButton o => ArrowType -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “direction
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> m ArrowType Source #
Get the value of the “direction
” property.
When overloading is enabled, this is equivalent to
get
menuButton #direction
setMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> ArrowType -> m () Source #
Set the value of the “direction
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #direction:=
value ]
menuModel
The MenuModel
from which the popup will be created.
Depending on the MenuButton
:use-popover
property, that may
be a menu or a popover.
See menuButtonSetMenuModel
for the interaction with the
MenuButton
:popup
property.
Since: 3.6
clearMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m () Source #
Set the value of the “menu-model
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#menuModel
constructMenuButtonMenuModel :: (IsMenuButton o, IsMenuModel a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “menu-model
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m (Maybe MenuModel) Source #
Get the value of the “menu-model
” property.
When overloading is enabled, this is equivalent to
get
menuButton #menuModel
setMenuButtonMenuModel :: (MonadIO m, IsMenuButton o, IsMenuModel a) => o -> a -> m () Source #
Set the value of the “menu-model
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #menuModel:=
value ]
popover
The Popover
that will be popped up when the button is clicked.
Since: 3.12
clearMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m () Source #
Set the value of the “popover
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#popover
constructMenuButtonPopover :: (IsMenuButton o, IsPopover a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “popover
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Popover) Source #
Get the value of the “popover
” property.
When overloading is enabled, this is equivalent to
get
menuButton #popover
setMenuButtonPopover :: (MonadIO m, IsMenuButton o, IsPopover a) => o -> a -> m () Source #
Set the value of the “popover
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #popover:=
value ]
popup
The Menu
that will be popped up when the button is clicked.
Since: 3.6
clearMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m () Source #
Set the value of the “popup
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#popup
constructMenuButtonPopup :: (IsMenuButton o, IsMenu a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “popup
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Menu) Source #
Get the value of the “popup
” property.
When overloading is enabled, this is equivalent to
get
menuButton #popup
setMenuButtonPopup :: (MonadIO m, IsMenuButton o, IsMenu a) => o -> a -> m () Source #
Set the value of the “popup
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #popup:=
value ]
usePopover
constructMenuButtonUsePopover :: IsMenuButton o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “use-popover
” property. This is rarely needed directly, but it is used by new
.
getMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> m Bool Source #
Get the value of the “use-popover
” property.
When overloading is enabled, this is equivalent to
get
menuButton #usePopover
setMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> Bool -> m () Source #
Set the value of the “use-popover
” property.
When overloading is enabled, this is equivalent to
set
menuButton [ #usePopover:=
value ]