gi-gtk3-3.0.44: Gtk 3.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.Button

Contents

- Exported types
- Methods
  - clicked
  - enter
  - getAlignment
  - getAlwaysShowImage
  - getEventWindow
  - getFocusOnClick
  - getImage
  - getImagePosition
  - getLabel
  - getRelief
  - getUseStock
  - getUseUnderline
  - leave
  - new
  - newFromIconName
  - newFromStock
  - newWithLabel
  - newWithMnemonic
  - pressed
  - released
  - setAlignment
  - setAlwaysShowImage
  - setFocusOnClick
  - setImage
  - setImagePosition
  - setLabel
  - setRelief
  - setUseStock
  - setUseUnderline
- Properties
  - alwaysShowImage
  - image
  - imagePosition
  - label
  - relief
  - useStock
  - useUnderline
  - xalign
  - yalign
- Signals
  - activate
  - clicked
  - enter
  - leave
  - pressed
  - released

Description

The `Button` widget is generally used to trigger a callback function that is called when the button is pressed. The various signals and how to use them are outlined below.

The `Button` widget can hold any valid child widget. That is, it can hold almost any other standard `Widget`. The most commonly used child is the `Label`.

# CSS nodes

GtkButton has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class.

Other style classes that are commonly used with GtkButton include .suggested-action and .destructive-action. In special cases, buttons can be made round by adding the .circular style class.

Button-like widgets like `ToggleButton`, `MenuButton`, `VolumeButton`, `LockButton`, `ColorButton`, `FontButton` or `FileChooserButton` use style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file to differentiate themselves from a plain GtkButton.

Synopsis

- newtype Button = Button (ManagedPtr Button)
- class (GObject o, IsDescendantOf Button o) => IsButton o
- toButton :: (MonadIO m, IsButton o) => o -> m Button
- buttonClicked :: (HasCallStack, MonadIO m, IsButton a) => a -> m ()
- buttonEnter :: (HasCallStack, MonadIO m, IsButton a) => a -> m ()
- buttonGetAlignment :: (HasCallStack, MonadIO m, IsButton a) => a -> m (Float, Float)
- buttonGetAlwaysShowImage :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonGetEventWindow :: (HasCallStack, MonadIO m, IsButton a) => a -> m Window
- buttonGetFocusOnClick :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonGetImage :: (HasCallStack, MonadIO m, IsButton a) => a -> m (Maybe Widget)
- buttonGetImagePosition :: (HasCallStack, MonadIO m, IsButton a) => a -> m PositionType
- buttonGetLabel :: (HasCallStack, MonadIO m, IsButton a) => a -> m Text
- buttonGetRelief :: (HasCallStack, MonadIO m, IsButton a) => a -> m ReliefStyle
- buttonGetUseStock :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonGetUseUnderline :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonLeave :: (HasCallStack, MonadIO m, IsButton a) => a -> m ()
- buttonNew :: (HasCallStack, MonadIO m) => m Button
- buttonNewFromIconName :: (HasCallStack, MonadIO m) => Maybe Text -> Int32 -> m Button
- buttonNewFromStock :: (HasCallStack, MonadIO m) => Text -> m Button
- buttonNewWithLabel :: (HasCallStack, MonadIO m) => Text -> m Button
- buttonNewWithMnemonic :: (HasCallStack, MonadIO m) => Text -> m Button
- buttonPressed :: (HasCallStack, MonadIO m, IsButton a) => a -> m ()
- buttonReleased :: (HasCallStack, MonadIO m, IsButton a) => a -> m ()
- buttonSetAlignment :: (HasCallStack, MonadIO m, IsButton a) => a -> Float -> Float -> m ()
- buttonSetAlwaysShowImage :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- buttonSetFocusOnClick :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- buttonSetImage :: (HasCallStack, MonadIO m, IsButton a, IsWidget b) => a -> Maybe b -> m ()
- buttonSetImagePosition :: (HasCallStack, MonadIO m, IsButton a) => a -> PositionType -> m ()
- buttonSetLabel :: (HasCallStack, MonadIO m, IsButton a) => a -> Text -> m ()
- buttonSetRelief :: (HasCallStack, MonadIO m, IsButton a) => a -> ReliefStyle -> m ()
- buttonSetUseStock :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- buttonSetUseUnderline :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- constructButtonAlwaysShowImage :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getButtonAlwaysShowImage :: (MonadIO m, IsButton o) => o -> m Bool
- setButtonAlwaysShowImage :: (MonadIO m, IsButton o) => o -> Bool -> m ()
- clearButtonImage :: (MonadIO m, IsButton o) => o -> m ()
- constructButtonImage :: (IsButton o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getButtonImage :: (MonadIO m, IsButton o) => o -> m (Maybe Widget)
- setButtonImage :: (MonadIO m, IsButton o, IsWidget a) => o -> a -> m ()
- constructButtonImagePosition :: (IsButton o, MonadIO m) => PositionType -> m (GValueConstruct o)
- getButtonImagePosition :: (MonadIO m, IsButton o) => o -> m PositionType
- setButtonImagePosition :: (MonadIO m, IsButton o) => o -> PositionType -> m ()
- constructButtonLabel :: (IsButton o, MonadIO m) => Text -> m (GValueConstruct o)
- getButtonLabel :: (MonadIO m, IsButton o) => o -> m Text
- setButtonLabel :: (MonadIO m, IsButton o) => o -> Text -> m ()
- constructButtonRelief :: (IsButton o, MonadIO m) => ReliefStyle -> m (GValueConstruct o)
- getButtonRelief :: (MonadIO m, IsButton o) => o -> m ReliefStyle
- setButtonRelief :: (MonadIO m, IsButton o) => o -> ReliefStyle -> m ()
- constructButtonUseStock :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getButtonUseStock :: (MonadIO m, IsButton o) => o -> m Bool
- setButtonUseStock :: (MonadIO m, IsButton o) => o -> Bool -> m ()
- constructButtonUseUnderline :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getButtonUseUnderline :: (MonadIO m, IsButton o) => o -> m Bool
- setButtonUseUnderline :: (MonadIO m, IsButton o) => o -> Bool -> m ()
- constructButtonXalign :: (IsButton o, MonadIO m) => Float -> m (GValueConstruct o)
- getButtonXalign :: (MonadIO m, IsButton o) => o -> m Float
- setButtonXalign :: (MonadIO m, IsButton o) => o -> Float -> m ()
- constructButtonYalign :: (IsButton o, MonadIO m) => Float -> m (GValueConstruct o)
- getButtonYalign :: (MonadIO m, IsButton o) => o -> m Float
- setButtonYalign :: (MonadIO m, IsButton o) => o -> Float -> m ()
- type ButtonActivateCallback = IO ()
- afterButtonActivate :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonActivateCallback) -> m SignalHandlerId
- onButtonActivate :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonActivateCallback) -> m SignalHandlerId
- type ButtonClickedCallback = IO ()
- afterButtonClicked :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonClickedCallback) -> m SignalHandlerId
- onButtonClicked :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonClickedCallback) -> m SignalHandlerId
- type ButtonEnterCallback = IO ()
- afterButtonEnter :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonEnterCallback) -> m SignalHandlerId
- onButtonEnter :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonEnterCallback) -> m SignalHandlerId
- type ButtonLeaveCallback = IO ()
- afterButtonLeave :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonLeaveCallback) -> m SignalHandlerId
- onButtonLeave :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonLeaveCallback) -> m SignalHandlerId
- type ButtonPressedCallback = IO ()
- afterButtonPressed :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonPressedCallback) -> m SignalHandlerId
- onButtonPressed :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonPressedCallback) -> m SignalHandlerId
- type ButtonReleasedCallback = IO ()
- afterButtonReleased :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonReleasedCallback) -> m SignalHandlerId
- onButtonReleased :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonReleasedCallback) -> m SignalHandlerId

# Exported types

newtype Button Source #

Memory-managed wrapper type.

Constructors

Button (ManagedPtr Button) |

#### Instances

Instances details

Eq Button Source # |
Instance details Defined in GI.Gtk.Objects.Button Methods (==) :: Button -> Button -> Bool Source # (/=) :: Button -> Button -> Bool Source #
GObject Button Source # |
Instance details Defined in GI.Gtk.Objects.Button
ManagedPtrNewtype Button Source # |
Instance details Defined in GI.Gtk.Objects.Button Methods toManagedPtr :: Button -> ManagedPtr Button Source #
TypedObject Button Source # |
Instance details Defined in GI.Gtk.Objects.Button Methods glibType :: IO GType Source #
HasParentTypes Button Source # |
Instance details Defined in GI.Gtk.Objects.Button
IsGValue (Maybe Button) Source # | Convert `Button` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.Button Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Button -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Button) Source #
type ParentTypes Button Source # |
Instance details Defined in GI.Gtk.Objects.Button type ParentTypes Button = '[Bin, Container, Widget, Object, ImplementorIface, Actionable, Activatable, Buildable]

class (GObject o, IsDescendantOf Button o) => IsButton o Source #

Type class for types which can be safely cast to `Button`, for instance with `toButton`.

#### Instances

Instances details

(GObject o, IsDescendantOf Button o) => IsButton o Source # |
Instance details Defined in GI.Gtk.Objects.Button

toButton :: (MonadIO m, IsButton o) => o -> m Button Source #

Cast to `Button`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

activate, add, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, checkResize, childFocus, childGetProperty, childNotify, childNotifyByPspec, childSetProperty, childType, classPath, clicked, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, doSetRelatedAction, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, enter, errorBell, event, forall, forceFloating, foreach, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, leave, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, pressed, propagateDraw, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, released, remove, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, resizeChildren, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, syncActionProperties, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetFocusChain, unsetStateFlags, watchClosure.

#### Getters

getAccessible, getActionGroup, getActionName, getActionTargetValue, getAlignment, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAlwaysShowImage, getAncestor, getAppPaintable, getBorderWidth, getCanDefault, getCanFocus, getChild, getChildRequisition, getChildVisible, getChildren, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEventWindow, getEvents, getFocusChain, getFocusChild, getFocusHadjustment, getFocusOnClick, getFocusVadjustment, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getImage, getImagePosition, getInternalChild, getLabel, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPathForChild, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRelatedAction, getRelief, getRequestMode, getRequisition, getResizeMode, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getUseActionAppearance, getUseStock, getUseUnderline, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.

#### Setters

setAccelPath, setActionName, setActionTargetValue, setAlignment, setAllocation, setAlwaysShowImage, setAppPaintable, setBorderWidth, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDetailedActionName, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusChain, setFocusChild, setFocusHadjustment, setFocusOnClick, setFocusVadjustment, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setImage, setImagePosition, setLabel, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReallocateRedraws, setReceivesDefault, setRedrawOnAllocate, setRelatedAction, setRelief, setResizeMode, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setUseActionAppearance, setUseStock, setUseUnderline, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.

## clicked

buttonClicked Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to send the signal to.
-> m () |

Emits a Button::clicked signal to the given `Button`.

## enter

buttonEnter Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to send the signal to.
-> m () |

Deprecated: (Since version 2.20)Use the Widget::enterNotifyEvent signal.

Emits a Button::enter signal to the given `Button`.

## getAlignment

buttonGetAlignment Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m (Float, Float) |

Deprecated: (Since version 3.14)Access the child widget directly if you need to controlits alignment.

Gets the alignment of the child in the button.

Since: 2.4

## getAlwaysShowImage

buttonGetAlwaysShowImage Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Bool | Returns: `True` if the button will always show the image

Returns whether the button will ignore the Settings:gtkButtonImages setting and always show the image, if available.

Since: 3.6

## getEventWindow

buttonGetEventWindow Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Window | Returns: `button`’s event window.

Returns the button’s event window if it is realized, `Nothing` otherwise. This function should be rarely needed.

Since: 2.22

## getFocusOnClick

buttonGetFocusOnClick Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Bool | Returns: `True` if the button grabs focus when it is clicked with the mouse.

Deprecated: (Since version 3.20)Use `widgetGetFocusOnClick` instead

Returns whether the button grabs focus when it is clicked with the mouse. See `buttonSetFocusOnClick`.

Since: 2.4

## getImage

buttonGetImage Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m (Maybe Widget) | Returns: a `Widget` or `Nothing` in case there is no image

Gets the widget that is currenty set as the image of `button`. This may have been explicitly set by `buttonSetImage` or constructed by `buttonNewFromStock`.

Since: 2.6

## getImagePosition

buttonGetImagePosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m PositionType | Returns: the position

Gets the position of the image relative to the text inside the button.

Since: 2.10

## getLabel

buttonGetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Text | Returns: The text of the label widget. This string is owned by the widget and must not be modified or freed.

Fetches the text from the label of the button, as set by `buttonSetLabel`. If the label text has not been set the return value will be `Nothing`. This will be the case if you create an empty button with `buttonNew` to use as a container.

## getRelief

buttonGetRelief Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want the `ReliefStyle` from.
-> m ReliefStyle | Returns: The current `ReliefStyle`

Returns the current relief style of the given `Button`.

## getUseStock

buttonGetUseStock Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Bool | Returns: `True` if the button label is used to select a stock item instead of being used directly as the label text.

Deprecated: (Since version 3.10)

Returns whether the button label is a stock item.

## getUseUnderline

buttonGetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> m Bool | Returns: `True` if an embedded underline in the button label indicates the mnemonic accelerator keys.

Returns whether an embedded underline in the button label indicates a mnemonic. See gtk_button_set_use_underline ().

## leave

buttonLeave Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to send the signal to.
-> m () |

Deprecated: (Since version 2.20)Use the Widget::leaveNotifyEvent signal.

Emits a Button::leave signal to the given `Button`.

## new

buttonNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Button | Returns: The newly created `Button` widget.

Creates a new `Button` widget. To add a child widget to the button, use `containerAdd`.

## newFromIconName

buttonNewFromIconName Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Text | `iconName`: an icon name or `Nothing`
-> Int32 | `size`: an icon size (t`IconSize`)
-> m Button | Returns: a new `Button` displaying the themed icon

Creates a new button containing an icon from the current icon theme.

If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.

This function is a convenience wrapper around `buttonNew` and `buttonSetImage`.

Since: 3.10

## newFromStock

buttonNewFromStock Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `stockId`: the name of the stock item
-> m Button | Returns: a new `Button`

Deprecated: (Since version 3.10)Stock items are deprecated. Use `buttonNewWithLabel`instead.

Creates a new `Button` containing the image and text from a [stock item][gtkstock]. Some stock ids have preprocessor macros like `STOCK_OK` and `STOCK_APPLY`.

If `stockId` is unknown, then it will be treated as a mnemonic label (as for `buttonNewWithMnemonic`).

## newWithLabel

buttonNewWithLabel Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `label`: The text you want the `Label` to hold.
-> m Button | Returns: The newly created `Button` widget.

Creates a `Button` widget with a `Label` child containing the given text.

## newWithMnemonic

buttonNewWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Text | `label`: The text of the button, with an underscore in front of the mnemonic character
-> m Button | Returns: a new `Button`

Creates a new `Button` containing a label. If characters in `label` are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.

## pressed

buttonPressed Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to send the signal to.
-> m () |

Deprecated: (Since version 2.20)Use the Widget::buttonPressEvent signal.

Emits a Button::pressed signal to the given `Button`.

## released

buttonReleased Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to send the signal to.
-> m () |

Deprecated: (Since version 2.20)Use the Widget::buttonReleaseEvent signal.

Emits a Button::released signal to the given `Button`.

## setAlignment

buttonSetAlignment Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Float | `xalign`: the horizontal position of the child, 0.0 is left aligned, 1.0 is right aligned
-> Float | `yalign`: the vertical position of the child, 0.0 is top aligned, 1.0 is bottom aligned
-> m () |

Deprecated: (Since version 3.14)Access the child widget directly if you need to controlits alignment.

Sets the alignment of the child. This property has no effect unless the child is a `Misc` or a `Alignment`.

Since: 2.4

## setAlwaysShowImage

buttonSetAlwaysShowImage Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Bool | `alwaysShow`: `True` if the menuitem should always show the image
-> m () |

If `True`, the button will ignore the Settings:gtkButtonImages setting and always show the image, if available.

Use this property if the button would be useless or hard to use without the image.

Since: 3.6

## setFocusOnClick

buttonSetFocusOnClick Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Bool | `focusOnClick`: whether the button grabs focus when clicked with the mouse
-> m () |

Deprecated: (Since version 3.20)Use `widgetSetFocusOnClick` instead

Sets whether the button will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.

Since: 2.4

## setImage

buttonSetImage Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a, IsWidget b) |
=> a | `button`: a `Button`
-> Maybe b | `image`: a widget to set as the image for the button, or `Nothing` to unset
-> m () |

Set the image of `button` to the given widget. The image will be displayed if the label text is `Nothing` or if Button:alwaysShowImage is `True`. You don’t have to call `widgetShow` on `image` yourself.

Since: 2.6

## setImagePosition

buttonSetImagePosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> PositionType | `position`: the position
-> m () |

Sets the position of the image relative to the text inside the button.

Since: 2.10

## setLabel

buttonSetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Text | `label`: a string
-> m () |

Sets the text of the label of the button to `str`. This text is also used to select the stock item if `buttonSetUseStock` is used.

This will also clear any previously set labels.

## setRelief

buttonSetRelief Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: The `Button` you want to set relief styles of
-> ReliefStyle | `relief`: The GtkReliefStyle as described above
-> m () |

Sets the relief style of the edges of the given `Button` widget. Two styles exist, `ReliefStyleNormal` and `ReliefStyleNone`. The default style is, as one can guess, `ReliefStyleNormal`. The deprecated value `ReliefStyleHalf` behaves the same as `ReliefStyleNormal`.

## setUseStock

buttonSetUseStock Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Bool | `useStock`: `True` if the button should use a stock item
-> m () |

Deprecated: (Since version 3.10)

If `True`, the label set on the button is used as a stock id to select the stock item for the button.

## setUseUnderline

buttonSetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsButton a) |
=> a | `button`: a `Button`
-> Bool | `useUnderline`: `True` if underlines in the text indicate mnemonics
-> m () |

If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.

# Properties

## alwaysShowImage

If `True`, the button will ignore the Settings:gtkButtonImages setting and always show the image, if available.

Use this property if the button would be useless or hard to use without the image.

Since: 3.6

constructButtonAlwaysShowImage :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`always-show-image`” property. This is rarely needed directly, but it is used by `new`.

getButtonAlwaysShowImage :: (MonadIO m, IsButton o) => o -> m Bool Source #

Get the value of the “`always-show-image`” property. When overloading is enabled, this is equivalent to

    get button #alwaysShowImage

setButtonAlwaysShowImage :: (MonadIO m, IsButton o) => o -> Bool -> m () Source #

Set the value of the “`always-show-image`” property. When overloading is enabled, this is equivalent to

    set button [ #alwaysShowImage := value ]

## image

The child widget to appear next to the button text.

Since: 2.6

clearButtonImage :: (MonadIO m, IsButton o) => o -> m () Source #

Set the value of the “`image`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #image

constructButtonImage :: (IsButton o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`image`” property. This is rarely needed directly, but it is used by `new`.

getButtonImage :: (MonadIO m, IsButton o) => o -> m (Maybe Widget) Source #

Get the value of the “`image`” property. When overloading is enabled, this is equivalent to

    get button #image

setButtonImage :: (MonadIO m, IsButton o, IsWidget a) => o -> a -> m () Source #

Set the value of the “`image`” property. When overloading is enabled, this is equivalent to

    set button [ #image := value ]

## imagePosition

The position of the image relative to the text inside the button.

Since: 2.10

constructButtonImagePosition :: (IsButton o, MonadIO m) => PositionType -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`image-position`” property. This is rarely needed directly, but it is used by `new`.

getButtonImagePosition :: (MonadIO m, IsButton o) => o -> m PositionType Source #

Get the value of the “`image-position`” property. When overloading is enabled, this is equivalent to

    get button #imagePosition

setButtonImagePosition :: (MonadIO m, IsButton o) => o -> PositionType -> m () Source #

Set the value of the “`image-position`” property. When overloading is enabled, this is equivalent to

    set button [ #imagePosition := value ]

## label

No description available in the introspection data.

constructButtonLabel :: (IsButton o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`label`” property. This is rarely needed directly, but it is used by `new`.

getButtonLabel :: (MonadIO m, IsButton o) => o -> m Text Source #

Get the value of the “`label`” property. When overloading is enabled, this is equivalent to

    get button #label

setButtonLabel :: (MonadIO m, IsButton o) => o -> Text -> m () Source #

Set the value of the “`label`” property. When overloading is enabled, this is equivalent to

    set button [ #label := value ]

## relief

No description available in the introspection data.

constructButtonRelief :: (IsButton o, MonadIO m) => ReliefStyle -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`relief`” property. This is rarely needed directly, but it is used by `new`.

getButtonRelief :: (MonadIO m, IsButton o) => o -> m ReliefStyle Source #

Get the value of the “`relief`” property. When overloading is enabled, this is equivalent to

    get button #relief

setButtonRelief :: (MonadIO m, IsButton o) => o -> ReliefStyle -> m () Source #

Set the value of the “`relief`” property. When overloading is enabled, this is equivalent to

    set button [ #relief := value ]

## useStock

No description available in the introspection data.

constructButtonUseStock :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`use-stock`” property. This is rarely needed directly, but it is used by `new`.

getButtonUseStock :: (MonadIO m, IsButton o) => o -> m Bool Source #

Get the value of the “`use-stock`” property. When overloading is enabled, this is equivalent to

    get button #useStock

setButtonUseStock :: (MonadIO m, IsButton o) => o -> Bool -> m () Source #

Set the value of the “`use-stock`” property. When overloading is enabled, this is equivalent to

    set button [ #useStock := value ]

## useUnderline

No description available in the introspection data.

constructButtonUseUnderline :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`use-underline`” property. This is rarely needed directly, but it is used by `new`.

getButtonUseUnderline :: (MonadIO m, IsButton o) => o -> m Bool Source #

Get the value of the “`use-underline`” property. When overloading is enabled, this is equivalent to

    get button #useUnderline

setButtonUseUnderline :: (MonadIO m, IsButton o) => o -> Bool -> m () Source #

Set the value of the “`use-underline`” property. When overloading is enabled, this is equivalent to

    set button [ #useUnderline := value ]

## xalign

If the child of the button is a `Misc` or `Alignment`, this property can be used to control its horizontal alignment. 0.0 is left aligned, 1.0 is right aligned.

Since: 2.4

constructButtonXalign :: (IsButton o, MonadIO m) => Float -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`xalign`” property. This is rarely needed directly, but it is used by `new`.

getButtonXalign :: (MonadIO m, IsButton o) => o -> m Float Source #

Get the value of the “`xalign`” property. When overloading is enabled, this is equivalent to

    get button #xalign

setButtonXalign :: (MonadIO m, IsButton o) => o -> Float -> m () Source #

Set the value of the “`xalign`” property. When overloading is enabled, this is equivalent to

    set button [ #xalign := value ]

## yalign

If the child of the button is a `Misc` or `Alignment`, this property can be used to control its vertical alignment. 0.0 is top aligned, 1.0 is bottom aligned.

Since: 2.4

constructButtonYalign :: (IsButton o, MonadIO m) => Float -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`yalign`” property. This is rarely needed directly, but it is used by `new`.

getButtonYalign :: (MonadIO m, IsButton o) => o -> m Float Source #

Get the value of the “`yalign`” property. When overloading is enabled, this is equivalent to

    get button #yalign

setButtonYalign :: (MonadIO m, IsButton o) => o -> Float -> m () Source #

Set the value of the “`yalign`” property. When overloading is enabled, this is equivalent to

    set button [ #yalign := value ]

# Signals

## activate

type ButtonActivateCallback = IO () Source #

The activate signal on GtkButton is an action signal and emitting it causes the button to animate press then release. Applications should never connect to this signal, but use the Button::clicked signal.

afterButtonActivate :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #activate callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonActivate :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonActivateCallback) -> m SignalHandlerId Source #

Connect a signal handler for the activate signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #activate callback

## clicked

type ButtonClickedCallback = IO () Source #

Emitted when the button has been activated (pressed and released).

afterButtonClicked :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonClickedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the clicked signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #clicked callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonClicked :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonClickedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the clicked signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #clicked callback

## enter

type ButtonEnterCallback = IO () Source #

Deprecated: (Since version 2.8)Use the Widget::enterNotifyEvent signal.

Emitted when the pointer enters the button.

afterButtonEnter :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonEnterCallback) -> m SignalHandlerId Source #

Connect a signal handler for the enter signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #enter callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonEnter :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonEnterCallback) -> m SignalHandlerId Source #

Connect a signal handler for the enter signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #enter callback

## leave

type ButtonLeaveCallback = IO () Source #

Deprecated: (Since version 2.8)Use the Widget::leaveNotifyEvent signal.

Emitted when the pointer leaves the button.

afterButtonLeave :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonLeaveCallback) -> m SignalHandlerId Source #

Connect a signal handler for the leave signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #leave callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonLeave :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonLeaveCallback) -> m SignalHandlerId Source #

Connect a signal handler for the leave signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #leave callback

## pressed

type ButtonPressedCallback = IO () Source #

Deprecated: (Since version 2.8)Use the Widget::buttonPressEvent signal.

Emitted when the button is pressed.

afterButtonPressed :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonPressedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the pressed signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #pressed callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonPressed :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonPressedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the pressed signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #pressed callback

## released

type ButtonReleasedCallback = IO () Source #

Deprecated: (Since version 2.8)Use the Widget::buttonReleaseEvent signal.

Emitted when the button is released.

afterButtonReleased :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonReleasedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the released signal, to be run after the default handler. When overloading is enabled, this is equivalent to

    after button #released callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit `?self` parameter. Note that this requires activating the `ImplicitParams` GHC extension.

onButtonReleased :: (IsButton a, MonadIO m) => a -> ((?self :: a) => ButtonReleasedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the released signal, to be run before the default handler. When overloading is enabled, this is equivalent to

    on button #released callback