Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
A widget that creates a signal when clicked on
- data Button
- class BinClass o => ButtonClass o
- castToButton :: GObjectClass obj => obj -> Button
- gTypeButton :: GType
- toButton :: ButtonClass o => o -> Button
- buttonNew :: IO Button
- buttonNewWithLabel :: GlibString string => string -> IO Button
- buttonNewWithMnemonic :: GlibString string => 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
- buttonSetRelief :: ButtonClass self => self -> ReliefStyle -> IO ()
- buttonGetRelief :: ButtonClass self => self -> IO ReliefStyle
- buttonSetLabel :: (ButtonClass self, GlibString string) => self -> string -> IO ()
- buttonGetLabel :: (ButtonClass self, GlibString string) => 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
- buttonSetImagePosition :: ButtonClass self => self -> PositionType -> IO ()
- buttonGetImagePosition :: ButtonClass self => self -> IO PositionType
- buttonGetEventWindow :: ButtonClass self => self -> IO (Maybe DrawWindow)
- buttonLabel :: (ButtonClass self, GlibString string) => 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
class BinClass o => ButtonClass o Source
castToButton :: GObjectClass obj => obj -> Button Source
toButton :: ButtonClass o => o -> Button Source
Constructors
Creates a new Button
widget. To add a child widget to the button, use
containerAdd
.
:: GlibString string | |
=> string |
|
-> IO Button |
:: GlibString string | |
=> string |
|
-> 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.
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 () Source
Emits the button pressed signal for the given Button
.
buttonReleased :: ButtonClass self => self -> IO () Source
Emits the button released signal for the given Button
.
buttonClicked :: ButtonClass self => self -> IO () Source
Emits the button clicked signal for the given Button
.
This is similar to calling buttonPressed
and buttonReleased
in sequence.
buttonEnter :: ButtonClass self => self -> IO () Source
Emit the cursor enters signal to the button.
buttonLeave :: ButtonClass self => self -> IO () Source
Emit the cursor leaves signal to the button.
data ReliefStyle Source
I don't have a clue.
:: ButtonClass self | |
=> self | |
-> ReliefStyle |
|
-> 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
.
:: ButtonClass self | |
=> self | |
-> IO ReliefStyle | returns The current |
Returns the current relief style of the given Button
.
buttonSetLabel :: (ButtonClass self, GlibString string) => self -> string -> IO () Source
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, GlibString string) => self -> IO string Source
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.
:: ButtonClass self | |
=> self | |
-> Bool |
|
-> 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.
:: ButtonClass self | |
=> self | |
-> IO Bool | returns |
Returns whether the button label is a stock item.
:: ButtonClass self | |
=> self | |
-> Bool |
|
-> 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.
:: ButtonClass self | |
=> self | |
-> IO Bool | returns |
Returns whether an embedded underline in the button label indicates a
mnemonic. See buttonSetUseUnderline
.
:: ButtonClass self | |
=> self | |
-> Bool |
|
-> 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
:: ButtonClass self | |
=> self | |
-> IO Bool | returns |
Returns whether the button grabs focus when it is clicked with the mouse.
See buttonSetFocusOnClick
.
- Available since Gtk version 2.4
:: ButtonClass self | |
=> self | |
-> (Float, Float) |
|
-> IO () |
:: ButtonClass self | |
=> self | |
-> IO (Float, Float) |
|
Gets the alignment of the child in the button.
- Available since Gtk version 2.4
:: ButtonClass self | |
=> self | |
-> IO (Maybe Widget) | a |
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
:: (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 Source
Position a scale's value is drawn relative to the trough
:: ButtonClass self | |
=> self | |
-> PositionType |
|
-> IO () |
Sets the position of the image relative to the text inside the button.
- Available since Gtk+ version 2.10
:: 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
:: ButtonClass self | |
=> self | |
-> IO (Maybe DrawWindow) | returns button's event window or |
Returns the button's event window if it is realized, Nothing
otherwise.
- Available since Gtk+ version 2.22
Attributes
buttonLabel :: (ButtonClass self, GlibString string) => Attr self string Source
Text of the label widget inside the button, if the button contains a label widget.
Default value: ""
buttonUseUnderline :: ButtonClass self => Attr self Bool Source
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 Source
If set, the label is used to pick a stock item instead of being displayed.
Default value: False
buttonFocusOnClick :: ButtonClass self => Attr self Bool Source
Whether the button grabs focus when it is clicked with the mouse.
Default value: True
buttonRelief :: ButtonClass self => Attr self ReliefStyle Source
The border relief style.
Default value: ReliefNormal
buttonXalign :: ButtonClass self => Attr self Float Source
buttonYalign :: ButtonClass self => Attr self Float Source
buttonImage :: (ButtonClass self, WidgetClass image) => ReadWriteAttr self (Maybe Widget) image Source
Child widget to appear next to the button text.
- Available since Gtk version 2.6
buttonImagePosition :: ButtonClass self => Attr self PositionType Source
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 ()) Source
Emitted when the button has been activated (pressed and released).
Deprecated
onButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button has been depressed (but not
necessarily released yet). See clicked
signal.
afterButtonActivate :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button has been depressed (but not
necessarily released yet). See clicked
signal.
onClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button was clicked. This is only emitted if the mouse cursor was over the button when it was released.
afterClicked :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button was clicked. This is only emitted if the mouse cursor was over the button when it was released.
afterEnter :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The cursor enters the button box.
afterLeave :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The cursor leaves the button box.
afterPressed :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button is pressed.
onReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button is released.
afterReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b) Source
The button is released.