Package ch.bailu.gtk.gtk
Klasse Button
- Alle implementierten Schnittstellen:
PointerInterface
- Bekannte direkte Unterklassen:
LinkButton
,LockButton
,ToggleButton
Calls a callback function when the button is clicked.
<picture>
<source srcset="button-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkButton" src="button.png">
</picture>
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`.
# Shortcuts and Gestures
The following signals have default keybindings:
- [signal@Gtk.Button::activate]
# 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.
When activating a button via the keyboard, the button will temporarily
gain the .keyboard-activating 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 [class@Gtk.ToggleButton], [class@Gtk.MenuButton],
[class@Gtk.VolumeButton], [class@Gtk.LockButton], [class@Gtk.ColorButton]
or [class@Gtk.FontButton] use style classes such as .toggle, .popup, .scale,
.lock, .color on the button node to differentiate themselves from a plain
`GtkButton`.
# Accessibility
`GtkButton` uses the [enum@Gtk.AccessibleRole.button] role.
<picture>
<source srcset="button-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkButton" src="button.png">
</picture>
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`.
# Shortcuts and Gestures
The following signals have default keybindings:
- [signal@Gtk.Button::activate]
# 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.
When activating a button via the keyboard, the button will temporarily
gain the .keyboard-activating 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 [class@Gtk.ToggleButton], [class@Gtk.MenuButton],
[class@Gtk.VolumeButton], [class@Gtk.LockButton], [class@Gtk.ColorButton]
or [class@Gtk.FontButton] use style classes such as .toggle, .popup, .scale,
.lock, .color on the button node to differentiate themselves from a plain
`GtkButton`.
# Accessibility
`GtkButton` uses the [enum@Gtk.AccessibleRole.button] role.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interface
static interface
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
FelderVon Klasse geerbte Felder ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungButton()
Creates a new `GtkButton` widget.Button
(PointerContainer pointer) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungImplements interfaceAccessible
.Implements interfaceActionable
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.boolean
Retrieves whether the button can be smaller than the natural
size of its contents.getChild()
Gets the child widget of @button.static ClassHandler
boolean
Returns whether the button has a frame.Returns the icon name of the button.static int
getLabel()
Fetches the text from the label of the button.static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
boolean
gets whether underlines are interpreted as mnemonics.static Button
newFromIconNameButton
(Str icon_name) Creates a new button containing an icon from the current icon theme.static Button
newFromIconNameButton
(String icon_name) Creates a new button containing an icon from the current icon theme.static Button
newWithLabelButton
(Str label) Creates a `GtkButton` widget with a `GtkLabel` child.static Button
newWithLabelButton
(String label) Creates a `GtkButton` widget with a `GtkLabel` child.static Button
newWithMnemonicButton
(Str label) Creates a new `GtkButton` containing a label.static Button
newWithMnemonicButton
(String label) Creates a new `GtkButton` containing a label.onActivate
(Button.OnActivate signal) Connect to signal "activate".onClicked
(Button.OnClicked signal) Connect to signal "clicked".void
setCanShrink
(boolean can_shrink) Sets whether the button size can be smaller than the natural size of
its contents.void
Sets the child widget of @button.void
setHasFrame
(boolean has_frame) Sets the style of the button.void
setIconName
(Str icon_name) Adds a `GtkImage` with the given icon name as a child.void
setIconName
(String icon_name) Adds a `GtkImage` with the given icon name as a child.void
Sets the text of the label of the button to @label.void
Sets the text of the label of the button to @label.void
setUseUnderline
(boolean use_underline) Sets whether to use underlines as mnemonics.Von Klasse geerbte Methoden ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
SIGNAL_ON_ACTIVATE
- Siehe auch:
-
SIGNAL_ON_CLICKED
- Siehe auch:
-
-
Konstruktordetails
-
Button
-
Button
public Button()Creates a new `GtkButton` widget.
To add a child widget to the button, use [method@Gtk.Button.set_child].
-
-
Methodendetails
-
getClassHandler
-
newFromIconNameButton
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.- Parameter:
icon_name
- an icon name- Gibt zurück:
- a new `GtkButton` displaying the themed icon
-
newFromIconNameButton
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.- Parameter:
icon_name
- an icon name- Gibt zurück:
- a new `GtkButton` displaying the themed icon
-
newWithLabelButton
Creates a `GtkButton` widget with a `GtkLabel` child.- Parameter:
label
- The text you want the `GtkLabel` to hold- Gibt zurück:
- The newly created `GtkButton` widget
-
newWithLabelButton
Creates a `GtkButton` widget with a `GtkLabel` child.- Parameter:
label
- The text you want the `GtkLabel` to hold- Gibt zurück:
- The newly created `GtkButton` widget
-
newWithMnemonicButton
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 <kbd>Alt</kbd> and that key
activates the button.- Parameter:
label
- The text of the button, with an underscore in front of the mnemonic character- Gibt zurück:
- a new `GtkButton`
-
newWithMnemonicButton
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 <kbd>Alt</kbd> and that key
activates the button.- Parameter:
label
- The text of the button, with an underscore in front of the mnemonic character- Gibt zurück:
- a new `GtkButton`
-
getCanShrink
public boolean getCanShrink()Retrieves whether the button can be smaller than the natural
size of its contents.- Gibt zurück:
- true if the button can shrink, and false otherwise
-
getChild
Gets the child widget of @button.- Gibt zurück:
- the child widget of @button
-
getHasFrame
public boolean getHasFrame()Returns whether the button has a frame.- Gibt zurück:
- %TRUE if the button has a frame
-
getIconName
Returns the icon name of the button.
If the icon name has not been set with [method@Gtk.Button.set_icon_name]
the return value will be %NULL. This will be the case if you create
an empty button with [ctor@Gtk.Button.new] to use as a container.- Gibt zurück:
- The icon name set via [method@Gtk.Button.set_icon_name]
-
getLabel
Fetches the text from the label of the button.
If the label text has not been set with [method@Gtk.Button.set_label]
the return value will be %NULL. This will be the case if you create
an empty button with [ctor@Gtk.Button.new] to use as a container.- Gibt zurück:
- The text of the label widget. This string is owned by the widget and must not be modified or freed.
-
getUseUnderline
public boolean getUseUnderline()gets whether underlines are interpreted as mnemonics.
See [method@Gtk.Button.set_use_underline].- Gibt zurück:
- %TRUE if an embedded underline in the button label indicates the mnemonic accelerator keys.
-
setCanShrink
public void setCanShrink(boolean can_shrink) Sets whether the button size can be smaller than the natural size of
its contents.
For text buttons, setting @can_shrink to true will ellipsize the label.
For icons and custom children, this function has no effect.- Parameter:
can_shrink
- whether the button can shrink
-
setChild
Sets the child widget of @button.
Note that by using this API, you take full responsibility for setting
up the proper accessibility label and description information for @button.
Most likely, you'll either set the accessibility label or description
for @button explicitly, or you'll set a labelled-by or described-by
relations from @child to @button.- Parameter:
child
- the child widget
-
setHasFrame
public void setHasFrame(boolean has_frame) Sets the style of the button.
Buttons can have a flat appearance or have a frame drawn around them.- Parameter:
has_frame
- whether the button should have a visible frame
-
setIconName
Adds a `GtkImage` with the given icon name as a child.
If @button already contains a child widget, that child widget will
be removed and replaced with the image.- Parameter:
icon_name
- An icon name
-
setIconName
Adds a `GtkImage` with the given icon name as a child.
If @button already contains a child widget, that child widget will
be removed and replaced with the image.- Parameter:
icon_name
- An icon name
-
setLabel
Sets the text of the label of the button to @label.
This will also clear any previously set labels.- Parameter:
label
- a string
-
setLabel
Sets the text of the label of the button to @label.
This will also clear any previously set labels.- Parameter:
label
- a string
-
setUseUnderline
public void setUseUnderline(boolean use_underline) Sets whether to use underlines as mnemonics.
If true, an underline in the text of the button label indicates
the next character should be used for the mnemonic accelerator key.- Parameter:
use_underline
- %TRUE if underlines in the text indicate mnemonics
-
onActivate
Connect to signal "activate".
SeeButton.OnActivate.onActivate()
for signal description.
FieldSIGNAL_ON_ACTIVATE
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onClicked
Connect to signal "clicked".
SeeButton.OnClicked.onClicked()
for signal description.
FieldSIGNAL_ON_CLICKED
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Setzt außer Kraft:
asAccessible
in KlasseWidget
- Gibt zurück:
Accessible
-
asActionable
Implements interfaceActionable
. Call this to get access to interface functions.- Gibt zurück:
Actionable
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Setzt außer Kraft:
asBuildable
in KlasseWidget
- Gibt zurück:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Setzt außer Kraft:
asConstraintTarget
in KlasseWidget
- Gibt zurück:
ConstraintTarget
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-