gtk-0.12.0: Binding to the Gtk+ graphical user interface library.

Portability | portable (depends on GHC)
Stability | provisional
Maintainer | gtk2hs-users@lists.sourceforge.net

Graphics.UI.Gtk.Buttons.Button

Contents

- Detail
- Class Hierarchy
- Types
- Constructors
- Methods
- Attributes
- Signals
- Deprecated

Description

A widget that creates a signal when clicked on

Synopsis

- data Button
- class BinClass o => ButtonClass o
- castToButton :: GObjectClass obj => obj -> Button
- gTypeButton :: GType
- toButton :: ButtonClass o => o -> Button
- buttonNew :: IO Button
- buttonNewWithLabel :: String -> IO Button
- buttonNewWithMnemonic :: String -> IO Button
- buttonNewFromStock :: StockId -> IO Button
- buttonPressed :: ButtonClass self => self -> IO ()
- buttonReleased :: ButtonClass self => self -> IO ()
- buttonClicked :: ButtonClass self => self -> IO ()
- buttonEnter :: ButtonClass self => self -> IO ()
- buttonLeave :: ButtonClass self => self -> IO ()
- data ReliefStyle
  - = ReliefNormal
  - | ReliefHalf
  - | ReliefNone
- buttonSetRelief :: ButtonClass self => self -> ReliefStyle -> IO ()
- buttonGetRelief :: ButtonClass self => self -> IO ReliefStyle
- buttonSetLabel :: ButtonClass self => self -> String -> IO ()
- buttonGetLabel :: ButtonClass self => self -> IO String
- buttonSetUseStock :: ButtonClass self => self -> Bool -> IO ()
- buttonGetUseStock :: ButtonClass self => self -> IO Bool
- buttonSetUseUnderline :: ButtonClass self => self -> Bool -> IO ()
- buttonGetUseUnderline :: ButtonClass self => self -> IO Bool
- buttonSetFocusOnClick :: ButtonClass self => self -> Bool -> IO ()
- buttonGetFocusOnClick :: ButtonClass self => self -> IO Bool
- buttonSetAlignment :: ButtonClass self => self -> (Float, Float) -> IO ()
- buttonGetAlignment :: ButtonClass self => self -> IO (Float, Float)
- buttonGetImage :: ButtonClass self => self -> IO (Maybe Widget)
- buttonSetImage :: (ButtonClass self, WidgetClass image) => self -> image -> IO ()
- data PositionType
  - = PosLeft
  - | PosRight
  - | PosTop
  - | PosBottom
- buttonSetImagePosition :: ButtonClass self => self -> PositionType -> IO ()
- buttonGetImagePosition :: ButtonClass self => self -> IO PositionType
- buttonGetEventWindow :: ButtonClass self => self -> IO (Maybe DrawWindow)
- buttonLabel :: ButtonClass self => Attr self String
- buttonUseUnderline :: ButtonClass self => Attr self Bool
- buttonUseStock :: ButtonClass self => Attr self Bool
- buttonFocusOnClick :: ButtonClass self => Attr self Bool
- buttonRelief :: ButtonClass self => Attr self ReliefStyle
- buttonXalign :: ButtonClass self => Attr self Float
- buttonYalign :: ButtonClass self => Attr self Float
- buttonImage :: (ButtonClass self, WidgetClass image) => ReadWriteAttr self (Maybe Widget) image
- buttonImagePosition :: ButtonClass self => Attr self PositionType
- buttonActivated :: ButtonClass self => Signal self (IO ())
- onButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- onClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- onEnter :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterEnter :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- onLeave :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterLeave :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- onPressed :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterPressed :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- onReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b)
- afterReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b)

# Detail

The `Button` widget is generally used to attach a function to 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 most any other standard `Widget`. The most commonly used child is the `Label`.

# Class Hierarchy

     | GObject
     | +----Object
     | +----Widget
     | +----Container
     | +----Bin
     | +----Button
     | +----ToggleButton
     | +----ColorButton
     | +----FontButton
     | +----OptionMenu

# Types

data Button

Instances

Eq Button |
Ord Button |
GObjectClass Button |
ButtonClass Button |
BinClass Button |
ContainerClass Button |
WidgetClass Button |
ObjectClass Button |

class BinClass o => ButtonClass o

Instances

ButtonClass OptionMenu |
ButtonClass FontButton |
ButtonClass ColorButton |
ButtonClass RadioButton |
ButtonClass CheckButton |
ButtonClass ToggleButton |
ButtonClass LinkButton |
ButtonClass VolumeButton |
ButtonClass ScaleButton |
ButtonClass Button |

castToButton :: GObjectClass obj => obj -> Button

gTypeButton :: GType

toButton :: ButtonClass o => o -> Button

# Constructors

buttonNew :: IO Button

Creates a new `Button` widget. To add a child widget to the button, use `Graphics.UI.Gtk.Abstract.Container.containerAdd`.

buttonNewWithLabel

Arguments

:: String | `label` - The text you want the `Label` to hold.
-> IO Button |

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

buttonNewWithMnemonic

Arguments

:: String | `label` - The text of the button, with an underscore in front of the mnemonic character
-> IO 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.

buttonNewFromStock

Arguments

:: StockId | `stockId` - the name of the stock item
-> IO Button |

Creates a new `Button` containing the image and text from a stock item.

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

# Methods

buttonPressed :: ButtonClass self => self -> IO ()

Emits the button pressed signal for the given `Button`.

buttonReleased :: ButtonClass self => self -> IO ()

Emits the button released signal for the given `Button`.

buttonClicked :: ButtonClass self => self -> IO ()

Emits the button clicked signal for the given `Button`.

This is similar to calling `buttonPressed` and `buttonReleased` in sequence.

buttonEnter :: ButtonClass self => self -> IO ()

Emit the cursor enters signal to the button.

buttonLeave :: ButtonClass self => self -> IO ()

Emit the cursor leaves signal to the button.

data ReliefStyle

I don't have a clue.

Constructors

ReliefNormal |
ReliefHalf |
ReliefNone |

Instances

Enum ReliefStyle |
Eq ReliefStyle |
Show ReliefStyle |

buttonSetRelief

Arguments

:: ButtonClass self |
=> self |
-> ReliefStyle | `newstyle` - The `ReliefStyle` as described above.
-> IO () |

Sets the relief style of the edges of the given `Button` widget. Three styles exist, `ReliefNormal`, `ReliefHalf`, `ReliefNone`. The default style is, as one can guess, `ReliefNormal`.

buttonGetRelief

Arguments

:: ButtonClass self |
=> self |
-> IO ReliefStyle | returns The current `ReliefStyle`

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

buttonSetLabel :: ButtonClass self => self -> String -> IO ()

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

This will also clear any previously set labels.

buttonGetLabel :: ButtonClass self => self -> IO String

Gets 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 `""`. This will be the case if you create an empty button with `buttonNew` to use as a container.

buttonSetUseStock

Arguments

:: ButtonClass self |
=> self |
-> Bool | `useStock` - `True` if the button should use a stock item
-> IO () |

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

Setting this property to `True` will make the button lookup its label in the table of stock items. If there is a match, the button will use the stock item instead of the label. You need to set this flag before you change the label.

buttonGetUseStock

Arguments

:: ButtonClass self |
=> self |
-> IO Bool | returns `True` if the button label is used to select a stock item instead of being used directly as the label text.

Returns whether the button label is a stock item.

buttonSetUseUnderline

Arguments

:: ButtonClass self |
=> self |
-> Bool | `useUnderline` - `True` if underlines in the text indicate mnemonics
-> IO () |

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

Setting this property will make the button join any underline character into the following letter and inserting this letter as a keyboard shortcut. You need to set this flag before you change the label.

buttonGetUseUnderline

Arguments

:: ButtonClass self |
=> self |
-> IO 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 `buttonSetUseUnderline`.

buttonSetFocusOnClick

Arguments

:: ButtonClass self |
=> self |
-> Bool | `focusOnClick` - whether the button grabs focus when clicked with the mouse
-> IO () |

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.

- Available since Gtk version 2.4

buttonGetFocusOnClick

Arguments

:: ButtonClass self |
=> self |
-> IO Bool | returns `True` if the button grabs focus when it is clicked with the mouse.

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

- Available since Gtk version 2.4

buttonSetAlignment

Arguments

:: ButtonClass self |
=> self |
-> (Float, Float) | `(xalign, yalign)` - the horizontal position of the child (0.0 is left aligned, 1.0 is right aligned) and the vertical position of the child (0.0 is top aligned, 1.0 is bottom aligned)
-> IO () |

Sets the alignment of the child. This has no effect unless the child derives from `Misc` or `Alignment`.

- Available since Gtk version 2.4

buttonGetAlignment

Arguments

:: ButtonClass self |
=> self |
-> IO (Float, Float) | `(xalign, yalign)` - horizontal and vertical alignment

Gets the alignment of the child in the button.

- Available since Gtk version 2.4

buttonGetImage

Arguments

:: ButtonClass self |
=> self |
-> IO (Maybe Widget) | a `Widget` or `Nothing` in case there is no image

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

- Available since Gtk+ version 2.6

buttonSetImage

Arguments

:: (ButtonClass self, WidgetClass image) |
=> self |
-> image | a widget to set as the image for the button
-> IO () |

Set the image of the button to the given widget. Note that it depends on the "gtk-button-images" setting whether the image will be displayed or not.

- Available since Gtk+ version 2.6

data PositionType

Position a scale's value is drawn relative to the trough

Constructors

PosLeft |
PosRight |
PosTop |
PosBottom |

Instances

Enum PositionType |
Eq PositionType |
Show PositionType |

buttonSetImagePosition

Arguments

:: ButtonClass self |
=> self |
-> PositionType | `position` - the position
-> IO () |

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

- Available since Gtk+ version 2.10

buttonGetImagePosition

Arguments

:: ButtonClass self |
=> self |
-> IO PositionType | returns the position

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

- Available since Gtk+ version 2.10

buttonGetEventWindow

Arguments

:: ButtonClass self |
=> self |
-> IO (Maybe DrawWindow) | returns button's event window or `Nothing`

Returns the button's event window if it is realized, `Nothing` otherwise.

- Available since Gtk+ version 2.22

# Attributes

buttonLabel :: ButtonClass self => Attr self String

Text of the label widget inside the button, if the button contains a label widget.

Default value: `""`

buttonUseUnderline :: ButtonClass self => Attr self Bool

If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Default value: `False`

buttonUseStock :: ButtonClass self => Attr self Bool

If set, the label is used to pick a stock item instead of being displayed.

Default value: `False`

buttonFocusOnClick :: ButtonClass self => Attr self Bool

Whether the button grabs focus when it is clicked with the mouse.

Default value: `True`

buttonRelief :: ButtonClass self => Attr self ReliefStyle

The border relief style.

Default value: `ReliefNormal`

buttonXalign :: ButtonClass self => Attr self Float

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

Allowed values: [0,1]

Default value: 0.5

buttonYalign :: ButtonClass self => Attr self Float

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

Allowed values: [0,1]

Default value: 0.5

buttonImage :: (ButtonClass self, WidgetClass image) => ReadWriteAttr self (Maybe Widget) image

Child widget to appear next to the button text.

- Available since Gtk version 2.6

buttonImagePosition :: ButtonClass self => Attr self PositionType

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

Default value: `PosLeft`

- Available since Gtk+ version 2.10

# Signals

buttonActivated :: ButtonClass self => Signal self (IO ())

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

# Deprecated

onButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The button has been depressed (but not necessarily released yet). See `clicked` signal.

onClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The button was clicked. This is only emitted if the mouse cursor was over the button when it was released.

onEnter :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterEnter :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The cursor enters the button box.

onLeave :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterLeave :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The cursor leaves the button box.

onPressed :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterPressed :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The button is pressed.

onReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b)

afterReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b)

The button is released.