GtkButton {RGtk2} | R Documentation

## GtkButton

### Description

A widget that creates a signal when clicked on

### Methods and Functions

`gtkButtonNew(show = TRUE)`
`gtkButtonNewWithLabel(label, show = TRUE)`
`gtkButtonNewWithMnemonic(label, show = TRUE)`
`gtkButtonNewFromStock(stock.id, show = TRUE)`
`gtkButtonPressed(object)`
`gtkButtonReleased(object)`
`gtkButtonClicked(object)`
`gtkButtonEnter(object)`
`gtkButtonLeave(object)`
`gtkButtonSetRelief(object, newstyle)`
`gtkButtonGetRelief(object)`
`gtkButtonGetLabel(object)`
`gtkButtonSetLabel(object, label)`
`gtkButtonGetUseStock(object)`
`gtkButtonSetUseStock(object, use.stock)`
`gtkButtonGetUseUnderline(object)`
`gtkButtonSetUseUnderline(object, use.underline)`
`gtkButtonSetFocusOnClick(object, focus.on.click)`
`gtkButtonGetFocusOnClick(object)`
`gtkButtonSetAlignment(object, xalign, yalign)`
`gtkButtonGetAlignment(object)`
`gtkButtonSetImage(object, image)`
`gtkButtonGetImage(object)`
`gtkButtonSetImagePosition(object, position)`
`gtkButtonGetImagePosition(object)`
`gtkButton(label, stock.id, show = TRUE)`

### Hierarchy

    GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkContainer
                               +----GtkBin
                                     +----GtkButton
                                           +----GtkToggleButton
                                           +----GtkColorButton
                                           +----GtkFontButton
                                           +----GtkLinkButton
                                           +----GtkOptionMenu
                                           +----GtkScaleButton

### Interfaces

GtkButton implements AtkImplementorIface, `GtkBuildable` and `GtkActivatable`.

### Detailed Description

The `GtkButton` 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 `GtkButton` widget can hold any valid child widget. That is it can hold most any other standard `GtkWidget`. The most commonly used child is the `GtkLabel`.

### Structures

`GtkButton`

  This should not be accessed directly. Use the accessor functions below.

### Convenient Construction

`gtkButton` is the result of collapsing the constructors of `GtkButton` (`gtkButtonNew`, `gtkButtonNewWithLabel`, `gtkButtonNewFromStock`, `gtkButtonNewWithMnemonic`) and accepts a subset of its arguments matching the required arguments of one of its delegate constructors.

### Signals

`activate(widget, user.data)`

  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 `gtkButtonClicked` signal.

  `widget`

    the object which received the signal.

  `user.data`

    user data set when the signal handler was connected.

`clicked(button, user.data)`

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

  `button`

    the object that received the signal

  `user.data`

    user data set when the signal handler was connected.

`enter(button, user.data)`

  Emitted when the pointer enters the button.

  `button`

    the object that received the signal

  `user.data`

    user data set when the signal handler was connected.

`leave(button, user.data)`

  Emitted when the pointer leaves the button.

  `button`

    the object that received the signal

  `user.data`

    user data set when the signal handler was connected.

`pressed(button, user.data)`

  Emitted when the button is pressed.

  `button`

    the object that received the signal

  `user.data`

    user data set when the signal handler was connected.

`released(button, user.data)`

  Emitted when the button is released.

  `button`

    the object that received the signal

  `user.data`

    user data set when the signal handler was connected.

### Properties

`focus-on-click` [logical : Read / Write]

  Whether the button grabs focus when it is clicked with the mouse. Default value: TRUE

`image` [`GtkWidget` : * : Read / Write]

  Child widget to appear next to the button text.

`image-position` [`GtkPositionType` : Read / Write]

  The position of the image relative to the text inside the button. Default value: GTK_POS_LEFT Since 2.10

`label` [character : * : Read / Write / Construct]

  Text of the label widget inside the button, if the button contains a label widget. Default value: NULL

`relief` [`GtkReliefStyle` : Read / Write]

  The border relief style. Default value: GTK_RELIEF_NORMAL

`use-stock` [logical : Read / Write / Construct]

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

`use-underline` [logical : Read / Write / Construct]

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

`xalign` [numeric : Read / Write]

  If the child of the button is a `GtkMisc` or `GtkAlignment`, 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 Since 2.4

`yalign` [numeric : Read / Write]

  If the child of the button is a `GtkMisc` or `GtkAlignment`, 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 Since 2.4

### Style Properties

`child-displacement-x` [integer : Read]

  How far in the x direction to move the child when the button is depressed. Default value: 0

`child-displacement-y` [integer : Read]

  How far in the y direction to move the child when the button is depressed. Default value: 0

`default-border` [`GtkBorder` : * : Read]

  The "default-border" style property defines the extra space to add around a button that can become the default widget of its window. For more information about default widgets, see `gtkWidgetGrabDefault`.

`default-outside-border` [`GtkBorder` : * : Read]

  The "default-outside-border" style property defines the extra outside space to add around a button that can become the default widget of its window. Extra outside space is always drawn outside the button border. For more information about default widgets, see `gtkWidgetGrabDefault`.

`displace-focus` [logical : Read]

  Whether the child_displacement_x/child_displacement_y properties should also affect the focus rectangle. Default value: FALSE Since 2.6

`image-spacing` [integer : Read]

  Spacing in pixels between the image and label. Allowed values: >= 0 Default value: 2

`inner-border` [`GtkBorder` : * : Read]

  Sets the border between the button edges and child. Since 2.10

### Author(s)

Derived by RGtkGen from GTK+ documentation

### References

https://developer.gnome.org/gtk2/stable/GtkButton.html

[Package RGtk2 version 2.20.36.3 Index]