gtk.Button

class Button : gtk.Bin.Bin, gtk.ActionableIF.ActionableIF, gtk.ActivatableIF.ActivatableIF;
The #GtkButton 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 #GtkButton widget can hold any valid child widget. That is, it can hold almost any other standard #GtkWidget. The most commonly used child is the #GtkLabel.

# 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 #GtkToggleButton, #GtkMenuButton, #GtkVolumeButton, #GtkLockButton, #GtkColorButton, #GtkFontButton or #GtkFileChooserButton use style classes such as .toggle, .popup, .scale, .lock, .color, .font, .file to differentiate themselves from a plain GtkButton.

protected GtkButton* gtkButton ;
the main Gtk struct

GtkButton* getButtonStruct ();
Get the main Gtk struct

protected void* getStruct ();
the main Gtk struct as a void*

this(GtkButton* gtkButton, bool ownedRef = false);
Sets our main struct and passes it to the parent class.

static void setIconSize (IconSize iconSize);
static IconSize getIconSize ();
this(string label, bool mnemonic = true);
Creates a new GtkButton 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.

Params:
string label The text of the button, with an underscore in front of the mnemonic character
bool mnemonic true if the button has an mnemnonic

Returns:
a new GtkButton

Throws:
ConstructionException GTK+ fails to create the object.

this(StockID stockID, bool hideLabel = false);
Creates a new GtkButton containing the image and text from a stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK and GTK_STOCK_APPLY. If stock_id is unknown, then it will be treated as a mnemonic label (as for gtk_button_new_with_mnemonic()).

Params:
StockID the name of the stock item

Throws:
ConstructionException GTK+ fails to create the object.

this(StockID stockID, void delegate(Button) dlg, bool hideLabel = false);
this(string label, void delegate(Button) dlg, bool mnemonic = true);
this(string label, void delegate(Button) dlg, string action);
static GType getType ();
this();
Creates a new #GtkButton widget. To add a child widget to the button, use gtk_container_add().

Returns:
The newly created #GtkButton widget.

Throws:
ConstructionException GTK+ fails to create the object.

this(string iconName, GtkIconSize size);
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 gtk_button_new() and gtk_button_set_image().

Params:
string iconName an icon name or %NULL
GtkIconSize size an icon size (#GtkIconSize)

Returns:
a new #GtkButton displaying the themed icon

Since:
3.10

Throws:
ConstructionException GTK+ fails to create the object.

void clicked ();
Emits a #GtkButton:: clicked signal to the given #GtkButton.

void enter ();
Emits a #GtkButton:: enter signal to the given #GtkButton.

Deprecated:
Use the #GtkWidget:: enter -notify-event signal.

void getAlignment (out float xalign, out float yalign);
Gets the alignment of the child in the button.

Deprecated:
Access the child widget directly if you need to control its alignment.

Params:
float xalign return location for horizontal alignment
float yalign return location for vertical alignment

Since:
2.4

bool getAlwaysShowImage ();
Returns whether the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.

Returns:
%TRUE if the button will always show the image

Since:
3.6

Window getEventWindow ();
Returns the button’s event window if it is realized, %NULL otherwise. This function should be rarely needed.

Returns:
@button’s event window.

Since:
2.22

bool getFocusOnClick ();
Returns whether the button grabs focus when it is clicked with the mouse. See gtk_button_set_focus_on_click().

Deprecated:
Use gtk_widget_get_focus_on_click() instead

Returns:
%TRUE if the button grabs focus when it is clicked with the mouse.

Since:
2.4

Widget getImage ();
Gets the widget that is currenty set as the image of @button. This may have been explicitly set by gtk_button_set_image() or constructed by gtk_button_new_from_stock().

Returns:
a #GtkWidget or %NULL in case there is no image

Since:
2.6

GtkPositionType getImagePosition ();
Gets the position of the image relative to the text inside the button.

Returns:
the position

Since:
2.10

string getLabel ();
Fetches the text from the label of the button, as set by gtk_button_set_label(). If the label text has not been set the return value will be %NULL. This will be the case if you create an empty button with gtk_button_new() to use as a container.

Returns:
The text of the label widget. This string is owned by the widget and must not be modified or freed.

GtkReliefStyle getRelief ();
Returns the current relief style of the given #GtkButton.

Returns:
The current #GtkReliefStyle

bool getUseStock ();
Returns whether the button label is a stock item.

Returns:
%TRUE if the button label is used to select a stock item instead of being used directly as the label text.

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

Returns:
%TRUE if an embedded underline in the button label indicates the mnemonic accelerator keys.

void leave ();
Emits a #GtkButton:: leave signal to the given #GtkButton.

Deprecated:
Use the #GtkWidget:: leave -notify-event signal.

void pressed ();
Emits a #GtkButton:: pressed signal to the given #GtkButton.

Deprecated:
Use the #GtkWidget::button-press-event signal.

void released ();
Emits a #GtkButton:: released signal to the given #GtkButton.

Deprecated:
Use the #GtkWidget::button-release-event signal.

void setAlignment (float xalign, float yalign);
Sets the alignment of the child. This property has no effect unless the child is a #GtkMisc or a #GtkAlignment.

Deprecated:
Access the child widget directly if you need to control its alignment.

Params:
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

Since:
2.4

void setAlwaysShowImage (bool alwaysShow);
If %TRUE, the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.

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

Params:
bool alwaysShow %TRUE if the menuitem should always show the image

Since:
3.6

void setFocusOnClick (bool focusOnClick);
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.

Deprecated:
Use gtk_widget_set_focus_on_click() instead

Params:
bool focusOnClick whether the button grabs focus when clicked with the mouse

Since:
2.4

void setImage (Widget image);
Set the image of @button to the given widget. The image will be displayed if the label text is %NULL or if #GtkButton:always-show-image is %TRUE. You don’t have to call gtk_widget_show() on @image yourself.

Params:
Widget image a widget to set as the image for the button

Since:
2.6

void setImagePosition (GtkPositionType position);
Sets the position of the image relative to the text inside the button.

Params:
GtkPositionType position the position

Since:
2.10

void setLabel (string label);
Sets the text of the label of the button to @str. This text is also used to select the stock item if gtk_button_set_use_stock() is used.

This will also clear any previously set labels.

Params:
string label a string

void setRelief (GtkReliefStyle relief);
Sets the relief style of the edges of the given #GtkButton widget. Two styles exist, %GTK_RELIEF_NORMAL and %GTK_RELIEF_NONE. The default style is, as one can guess, %GTK_RELIEF_NORMAL. The deprecated value %GTK_RELIEF_HALF behaves the same as %GTK_RELIEF_NORMAL.

Params:
GtkReliefStyle relief The GtkReliefStyle as described above

void setUseStock (bool useStock);
If %TRUE, the label set on the button is used as a stock id to select the stock item for the button.

Params:
bool useStock %TRUE if the button should use a stock item

void setUseUnderline (bool useUnderline);
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.

Params:
bool useUnderline %TRUE if underlines in the text indicate mnemonics

gulong addOnActivate (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
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 #GtkButton::clicked signal.

gulong addOnClicked (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the button has been activated (pressed and released).

gulong addOnEnter (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the pointer enters the button.

Deprecated:
Use the #GtkWidget::enter-notify-event signal.

gulong addOnLeave (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the pointer leaves the button.

Deprecated:
Use the #GtkWidget::leave-notify-event signal.

gulong addOnPressed (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the button is pressed.

Deprecated:
Use the #GtkWidget::button-press-event signal.

gulong addOnReleased (void delegate(Button) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the button is released.

Deprecated:
Use the #GtkWidget::button-release-event signal.

Page was generated with on Sun Apr 23 22:52:56 2017