gtk.button
Module for [Button] class
Types 3
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.
ButtonGidBuilder builder() static nothrowGet builder for [gtk.button.Button] Returns: New builder objectbool alwaysShowImage() @property nothrowGet `alwaysShowImage` property. Returns: If true, the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.void alwaysShowImage(bool propval) @property nothrowSet `alwaysShowImage` property. Params: propval = If true, the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.gtk.widget.Widget image() @property nothrowGet `image` property. Returns: The child widget to appear next to the button text.void image(gtk.widget.Widget propval) @property nothrowSet `image` property. Params: propval = The child widget to appear next to the button text.gtk.types.PositionType imagePosition() @property nothrowGet `imagePosition` property. Returns: The position of the image relative to the text inside the button.void imagePosition(gtk.types.PositionType propval) @property nothrowSet `imagePosition` property. Params: propval = The position of the image relative to the text inside the button.float xalign() @property nothrowGet `xalign` property. Returns: If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its horizontal alignment. 0.0 is left aligned, 1.0 is right aligned.void xalign(float propval) @property nothrowSet `xalign` property. Params: propval = If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its horizontal alignment. 0.0 is left aligned, 1.0 is right ...float yalign() @property nothrowGet `yalign` property. Returns: If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its vertical alignment. 0.0 is top aligned, 1.0 is bottom aligned.void yalign(float propval) @property nothrowSet `yalign` property. Params: propval = If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its vertical alignment. 0.0 is top aligned, 1.0 is bottom al...gtk.button.Button newFromIconName(string iconName, gtk.types.IconSize size) static nothrowCreates a new button containing an icon from the current icon theme.gtk.button.Button newFromStock(string stockId) static nothrowCreates a new #GtkButton containing the image and text from a [stock item][gtkstock]. Some stock ids have preprocessor macros like #GTK_STOCK_OK and #GTK_STOCK_APPLY.gtk.button.Button newWithLabel(string label) static nothrowCreates a #GtkButton widget with a #GtkLabel child containing the given text.gtk.button.Button newWithMnemonic(string label) static nothrowCreates 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 unde...void getAlignment(out float xalign, out float yalign) nothrowGets the alignment of the child in the button.bool getAlwaysShowImage() nothrowReturns 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 imagegdk.window.Window getEventWindow() nothrowReturns the button’s event window if it is realized, null otherwise. This function should be rarely needed. Returns: button’s event window.bool getFocusOnClick() nothrowReturns whether the button grabs focus when it is clicked with the mouse. See [gtk.button.Button.setFocusOnClick]. Returns: true if the button grabs focus when it is clicked with the mouse.gtk.widget.Widget getImage() nothrowGets the widget that is currenty set as the image of button. This may have been explicitly set by [gtk.button.Button.setImage] or constructed by [gtk.button.Button.newFromStock]. Returns: a #GtkWid...gtk.types.PositionType getImagePosition() nothrowGets the position of the image relative to the text inside the button. Returns: the positionstring getLabel() nothrowFetches the text from the label of the button, as set by [gtk.button.Button.setLabel]. If the label text has not been set the return value will be null. This will be the case if you create an empty...gtk.types.ReliefStyle getRelief() nothrowReturns the current relief style of the given #GtkButton. Returns: The current #GtkReliefStylebool getUseStock() nothrowReturns 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() nothrowReturns 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 mnemoni...void setAlignment(float xalign, float yalign) nothrowSets the alignment of the child. This property has no effect unless the child is a #GtkMisc or a #GtkAlignment.void setAlwaysShowImage(bool alwaysShow) nothrowIf true, the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.void setFocusOnClick(bool focusOnClick) nothrowSets 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 fro...void setImage(gtk.widget.Widget image = null) nothrowSet 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.Widget.show] on i...void setImagePosition(gtk.types.PositionType position) nothrowSets the position of the image relative to the text inside the button.void setLabel(string label) nothrowSets the text of the label of the button to str. This text is also used to select the stock item if [gtk.button.Button.setUseStock] is used.void setRelief(gtk.types.ReliefStyle relief) nothrowSets the relief style of the edges of the given #GtkButton widget. Two styles exist, [gtk.types.ReliefStyle.Normal] and [gtk.types.ReliefStyle.None]. The default style is, as one can guess, [gtk.ty...void setUseStock(bool useStock) nothrowIf true, the label set on the button is used as a stock id to select the stock item for the button.void setUseUnderline(bool useUnderline) nothrowIf true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Activate` signal.gulong connectClicked(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Clicked` signal.gulong connectEnter(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Enter` signal.gulong connectLeave(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Leave` signal.gulong connectPressed(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Pressed` signal.gulong connectReleased(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.button.Button)))
&& Parameters!T.length < 2) nothrowConnect to `Released` signal.Fluent builder implementation template for gtk.button.Button
T alwaysShowImage(bool propval) nothrowSet `alwaysShowImage` property. Params: propval = If true, the button will ignore the #GtkSettings:gtk-button-images setting and always show the image, if available.T image(gtk.widget.Widget propval) nothrowSet `image` property. Params: propval = The child widget to appear next to the button text. Returns: Builder instance for fluent chainingT imagePosition(gtk.types.PositionType propval) nothrowSet `imagePosition` property. Params: propval = The position of the image relative to the text inside the button. Returns: Builder instance for fluent chainingT label(string propval) nothrowT relief(gtk.types.ReliefStyle propval) nothrowT useStock(bool propval) nothrowT useUnderline(bool propval) nothrowT xalign(float propval) nothrowSet `xalign` property. Params: propval = If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its horizontal alignment. 0.0 is left aligned, 1.0 is right ...T yalign(float propval) nothrowSet `yalign` property. Params: propval = If the child of the button is a #GtkMisc or #GtkAlignment, this property can be used to control its vertical alignment. 0.0 is top aligned, 1.0 is bottom al...Fluent builder for gtk.button.Button