reckfellENGINE

Button

Button with text, an icon and theme-based styling.

On this page
class ButtonReckfellSharpInherits BaseButton

Button adds visuals to BaseButton behavior. Use Pressed for an action; enable ToggleMode and use Toggled for a persistent setting. Text and Icon define content; theme resources define state styles, fonts, colors and spacing. Defaults are centered text, left/vertically centered icon and MouseFilter = Stop.

Why a long button will not shrink: without ClipText, trimming or wrapping, text width contributes to minimum size. For a single-line ellipsis button, set TextOverrunBehavior = TextServer.OverrunBehavior.TrimEllipsisForce and constrain available width through parent layout. ClipText alone permits clipping without adding an ellipsis. CustomMinimumSize, icon size and StyleBox margins still constrain size.

AutowrapMode enables wrapping; WordSmart wraps words and breaks oversized fragments. Available width must be defined or there is no reason to wrap. Wrapping changes required height; avoid fixed heights for translations of different lengths. AutowrapTrimFlags only controls spaces at line edges: unrelated LineBreakFlag bits are discarded.

With ExpandIcon = false, source icon size contributes to minimum size; theme constant icon_max_width caps it while preserving aspect ratio. ExpandIcon = true fits the icon into available space and removes its source size from the minimum, without automatically creating spare room. IconAlignment and VerticalIconAlignment are independent of text Alignment; top/bottom icons can require additional height.

Icon = null can use the theme icon named icon. GetButtonIcon therefore returns only the explicitly assigned texture rather than necessarily the one drawn. The icon resource is shared and changes are observed. Flat suppresses background StyleBoxes while retaining separate focus styling, sizing and input handling. Use consistent state-style margins for stable sizing.

GetText returns source text rather than its translation or trimmed display. Language sets shaping language rather than switching the application locale. TextDirection sets paragraph direction; horizontal icon/text alignment mirroring follows the Control’s LayoutDirection.

Assign a shared Shortcut resource for a key binding. MatchesEvent can also match release events: matching alone is not button activation. BaseButton additionally checks pressing, echo, visibility and Disabled.

BaseButton. Shortcut.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

ButtonConstructor
# Button
C#
public Button();

Creates a button with empty Text, no explicit Icon, Alignment = Center, IconAlignment = Left and VerticalIconAlignment = Center. Flat/ClipText/ExpandIcon are off; MouseFilter = Stop.

Properties13

AlignmentProperty
# Alignment
C#
public HorizontalAlignment Alignment { get; set; }

Horizontal text alignment, default Center. Left/Right mirror with the Control’s RTL LayoutDirection. Does not position the button in its parent or replace IconAlignment.

AutowrapModeProperty
# AutowrapMode
C#
public TextServer.AutowrapMode AutowrapMode { get; set; }

Wrapping mode, default Off. Word/WordSmart use word boundaries; Arbitrary uses grapheme boundaries. Requires bounded available width. Releases natural text minimum width but can increase required height.

AutowrapTrimFlagsProperty
# AutowrapTrimFlags
C#
public TextServer.LineBreakFlag AutowrapTrimFlags { get; set; }

Line-edge space trimming bits; default TrimEndEdgeSpaces. Only TrimStartEdgeSpaces/TrimEndEdgeSpaces are retained; other LineBreakFlag bits are discarded. AutowrapMode separately selects wrapping.

ClipTextProperty
# ClipText
C#
public bool ClipText { get; set; }

Permits text clipping and removes natural text width from minimum size, default false. Does not add an ellipsis or remove style margins, icon size or CustomMinimumSize.

ExpandIconProperty
# ExpandIcon
C#
public bool ExpandIcon { get; set; }

Fit the icon into available space while preserving aspect ratio, default false. true removes source icon size from minimum size. Theme icon_max_width still applies; layout determines available space.

FlatProperty
# Flat
C#
public bool Flat { get; set; }

Suppress background StyleBoxes, default false. Separate focus style still draws; minimum size, style margins, click handling and Disabled keep their usual behavior.

IconProperty
# Icon
C#
public Texture2D Icon { get; set; }

Explicit shared Texture2D, or null. With null, display can use the theme icon named icon. Resource is not copied and changes are observed. Minimum-size contribution depends on ExpandIcon and icon_max_width.

IconAlignmentProperty
# IconAlignment
C#
public HorizontalAlignment IconAlignment { get; set; }

Horizontal icon alignment, default Left. Left/Right mirror in RTL. Center changes shared-space calculation rather than automatically adding icon/text padding.

LanguageProperty
# Language
C#
public string Language { get; set; }

Shaping language; empty uses the Control locale. A text-processing hint rather than an application-locale switch or a translated Text result.

TextProperty
# Text
C#
public string Text { get; set; }

Source label text, empty by default. Display can be translated, wrapped and trimmed; the getter returns the source. Changes refresh shaping and minimum size. Plain text rather than BBCode markup.

TextDirectionProperty
# TextDirection
C#
public Control.TextDirection TextDirection { get; set; }

Text-processing direction, default Auto. Inherited uses Control layout direction. Does not replace LayoutDirection for mirroring icon placement and horizontal alignment.

TextOverrunBehaviorProperty
# TextOverrunBehavior
C#
public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }

Trimming when width is insufficient, default NoTrimming. TrimChar/TrimWord trim; Ellipsis modes add an ellipsis under their conditions, while Force permits short-label ellipses. Does not change source Text and requires a bounded area.

VerticalIconAlignmentProperty
# VerticalIconAlignment
C#
public VerticalAlignment VerticalIconAlignment { get; set; }

Vertical icon alignment, default Center. Top/Bottom can add text and icon heights, increasing minimum size. Does not change parent-layout alignment of the Control.

Methods26

GetAutowrapModeTextServer.AutowrapMode
# GetAutowrapMode
C#
public TextServer.AutowrapMode GetAutowrapMode();

Wrapping mode, default Off. Word/WordSmart use word boundaries; Arbitrary uses grapheme boundaries. Requires bounded available width. Releases natural text minimum width but can increase required height.

Returns TextServer.AutowrapMode

Selected TextServer.AutowrapMode.

GetAutowrapTrimFlagsTextServer.LineBreakFlag
# GetAutowrapTrimFlags
C#
public TextServer.LineBreakFlag GetAutowrapTrimFlags();

Line-edge space trimming bits; default TrimEndEdgeSpaces. Only TrimStartEdgeSpaces/TrimEndEdgeSpaces are retained; other LineBreakFlag bits are discarded. AutowrapMode separately selects wrapping.

Returns TextServer.LineBreakFlag

Stored line-edge space trimming bits.

GetButtonIconTexture2D
# GetButtonIcon
C#
public Texture2D GetButtonIcon();

Explicit shared Texture2D, or null. With null, display can use the theme icon named icon. Resource is not copied and changes are observed. Minimum-size contribution depends on ExpandIcon and icon_max_width.

Returns Texture2D

Explicit shared Texture2D, or null even when a theme icon is drawn.

GetClipTextbool
# GetClipText
C#
public bool GetClipText();

Permits text clipping and removes natural text width from minimum size, default false. Does not add an ellipsis or remove style margins, icon size or CustomMinimumSize.

Returns bool

true when text clipping is enabled.

GetIconAlignmentHorizontalAlignment
# GetIconAlignment
C#
public HorizontalAlignment GetIconAlignment();

Horizontal icon alignment, default Left. Left/Right mirror in RTL. Center changes shared-space calculation rather than automatically adding icon/text padding.

Returns HorizontalAlignment

Horizontal icon alignment before RTL mirroring.

GetLanguagestring
# GetLanguage
C#
public string GetLanguage();

Shaping language; empty uses the Control locale. A text-processing hint rather than an application-locale switch or a translated Text result.

Returns string

Stored language code, or empty for the Control locale.

GetTextstring
# GetText
C#
public string GetText();

Source label text, empty by default. Display can be translated, wrapped and trimmed; the getter returns the source. Changes refresh shaping and minimum size. Plain text rather than BBCode markup.

Returns string

Source string before translation and trimming.

GetTextAlignmentHorizontalAlignment
# GetTextAlignment
C#
public HorizontalAlignment GetTextAlignment();

Horizontal text alignment, default Center. Left/Right mirror with the Control’s RTL LayoutDirection. Does not position the button in its parent or replace IconAlignment.

Returns HorizontalAlignment

Horizontal text alignment before RTL mirroring.

GetTextDirectionControl.TextDirection
# GetTextDirection
C#
public Control.TextDirection GetTextDirection();

Text-processing direction, default Auto. Inherited uses Control layout direction. Does not replace LayoutDirection for mirroring icon placement and horizontal alignment.

Returns Control.TextDirection

Stored Control.TextDirection.

GetTextOverrunBehaviorTextServer.OverrunBehavior
# GetTextOverrunBehavior
C#
public TextServer.OverrunBehavior GetTextOverrunBehavior();

Trimming when width is insufficient, default NoTrimming. TrimChar/TrimWord trim; Ellipsis modes add an ellipsis under their conditions, while Force permits short-label ellipses. Does not change source Text and requires a bounded area.

Returns TextServer.OverrunBehavior

Selected TextServer.OverrunBehavior.

GetVerticalIconAlignmentVerticalAlignment
# GetVerticalIconAlignment
C#
public VerticalAlignment GetVerticalIconAlignment();

Vertical icon alignment, default Center. Top/Bottom can add text and icon heights, increasing minimum size. Does not change parent-layout alignment of the Control.

Returns VerticalAlignment

Stored vertical icon alignment.

IsExpandIconbool
# IsExpandIcon
C#
public bool IsExpandIcon();

Fit the icon into available space while preserving aspect ratio, default false. true removes source icon size from minimum size. Theme icon_max_width still applies; layout determines available space.

Returns bool

true when the icon is fitted to available space.

IsFlatbool
# IsFlat
C#
public bool IsFlat();

Suppress background StyleBoxes, default false. Separate focus style still draws; minimum size, style margins, click handling and Disabled keep their usual behavior.

Returns bool

true when background StyleBoxes are suppressed.

SetAutowrapModevoid
# SetAutowrapMode
C#
public void SetAutowrapMode(TextServer.AutowrapMode autowrapMode);

Wrapping mode, default Off. Word/WordSmart use word boundaries; Arbitrary uses grapheme boundaries. Requires bounded available width. Releases natural text minimum width but can increase required height.

Parameters
NameTypeDefault
autowrapModeTextServer.AutowrapMode—
autowrapMode

Wrapping mode, default Off. Word/WordSmart use word boundaries; Arbitrary uses grapheme boundaries. Requires bounded available width. Releases natural text minimum width but can increase required height.

SetAutowrapTrimFlagsvoid
# SetAutowrapTrimFlags
C#
public void SetAutowrapTrimFlags(TextServer.LineBreakFlag autowrapTrimFlags);

Line-edge space trimming bits; default TrimEndEdgeSpaces. Only TrimStartEdgeSpaces/TrimEndEdgeSpaces are retained; other LineBreakFlag bits are discarded. AutowrapMode separately selects wrapping.

Parameters
NameTypeDefault
autowrapTrimFlagsTextServer.LineBreakFlag—
autowrapTrimFlags

Line-edge space trimming bits; default TrimEndEdgeSpaces. Only TrimStartEdgeSpaces/TrimEndEdgeSpaces are retained; other LineBreakFlag bits are discarded. AutowrapMode separately selects wrapping.

SetButtonIconvoid
# SetButtonIcon
C#
public void SetButtonIcon(Texture2D texture);

Explicit shared Texture2D, or null. With null, display can use the theme icon named icon. Resource is not copied and changes are observed. Minimum-size contribution depends on ExpandIcon and icon_max_width.

Parameters
NameTypeDefault
textureTexture2D—
texture

Explicit shared Texture2D, or null. With null, display can use the theme icon named icon. Resource is not copied and changes are observed. Minimum-size contribution depends on ExpandIcon and icon_max_width.

SetClipTextvoid
# SetClipText
C#
public void SetClipText(bool enabled);

Permits text clipping and removes natural text width from minimum size, default false. Does not add an ellipsis or remove style margins, icon size or CustomMinimumSize.

Parameters
NameTypeDefault
enabledbool—
enabled

Permits text clipping and removes natural text width from minimum size, default false. Does not add an ellipsis or remove style margins, icon size or CustomMinimumSize.

SetExpandIconvoid
# SetExpandIcon
C#
public void SetExpandIcon(bool enabled);

Fit the icon into available space while preserving aspect ratio, default false. true removes source icon size from minimum size. Theme icon_max_width still applies; layout determines available space.

Parameters
NameTypeDefault
enabledbool—
enabled

Fit the icon into available space while preserving aspect ratio, default false. true removes source icon size from minimum size. Theme icon_max_width still applies; layout determines available space.

SetFlatvoid
# SetFlat
C#
public void SetFlat(bool enabled);

Suppress background StyleBoxes, default false. Separate focus style still draws; minimum size, style margins, click handling and Disabled keep their usual behavior.

Parameters
NameTypeDefault
enabledbool—
enabled

Suppress background StyleBoxes, default false. Separate focus style still draws; minimum size, style margins, click handling and Disabled keep their usual behavior.

SetIconAlignmentvoid
# SetIconAlignment
C#
public void SetIconAlignment(HorizontalAlignment iconAlignment);

Horizontal icon alignment, default Left. Left/Right mirror in RTL. Center changes shared-space calculation rather than automatically adding icon/text padding.

Parameters
NameTypeDefault
iconAlignmentHorizontalAlignment—
iconAlignment

Horizontal icon alignment, default Left. Left/Right mirror in RTL. Center changes shared-space calculation rather than automatically adding icon/text padding.

SetLanguagevoid
# SetLanguage
C#
public void SetLanguage(string language);

Shaping language; empty uses the Control locale. A text-processing hint rather than an application-locale switch or a translated Text result.

Parameters
NameTypeDefault
languagestring—
language

Shaping language; empty uses the Control locale. A text-processing hint rather than an application-locale switch or a translated Text result.

SetTextvoid
# SetText
C#
public void SetText(string text);

Source label text, empty by default. Display can be translated, wrapped and trimmed; the getter returns the source. Changes refresh shaping and minimum size. Plain text rather than BBCode markup.

Parameters
NameTypeDefault
textstring—
text

Source label text, empty by default. Display can be translated, wrapped and trimmed; the getter returns the source. Changes refresh shaping and minimum size. Plain text rather than BBCode markup.

SetTextAlignmentvoid
# SetTextAlignment
C#
public void SetTextAlignment(HorizontalAlignment alignment);

Horizontal text alignment, default Center. Left/Right mirror with the Control’s RTL LayoutDirection. Does not position the button in its parent or replace IconAlignment.

Parameters
NameTypeDefault
alignmentHorizontalAlignment—
alignment

Horizontal text alignment, default Center. Left/Right mirror with the Control’s RTL LayoutDirection. Does not position the button in its parent or replace IconAlignment.

SetTextDirectionvoid
# SetTextDirection
C#
public void SetTextDirection(Control.TextDirection direction);

Text-processing direction, default Auto. Inherited uses Control layout direction. Does not replace LayoutDirection for mirroring icon placement and horizontal alignment.

Parameters
NameTypeDefault
directionControl.TextDirection—
direction

Text-processing direction, default Auto. Inherited uses Control layout direction. Does not replace LayoutDirection for mirroring icon placement and horizontal alignment.

SetTextOverrunBehaviorvoid
# SetTextOverrunBehavior
C#
public void SetTextOverrunBehavior(TextServer.OverrunBehavior overrunBehavior);

Trimming when width is insufficient, default NoTrimming. TrimChar/TrimWord trim; Ellipsis modes add an ellipsis under their conditions, while Force permits short-label ellipses. Does not change source Text and requires a bounded area.

Parameters
NameTypeDefault
overrunBehaviorTextServer.OverrunBehavior—
overrunBehavior

Trimming when width is insufficient, default NoTrimming. TrimChar/TrimWord trim; Ellipsis modes add an ellipsis under their conditions, while Force permits short-label ellipses. Does not change source Text and requires a bounded area.

SetVerticalIconAlignmentvoid
# SetVerticalIconAlignment
C#
public void SetVerticalIconAlignment(VerticalAlignment verticalIconAlignment);

Vertical icon alignment, default Center. Top/Bottom can add text and icon heights, increasing minimum size. Does not change parent-layout alignment of the Control.

Parameters
NameTypeDefault
verticalIconAlignmentVerticalAlignment—
verticalIconAlignment

Vertical icon alignment, default Center. Top/Bottom can add text and icon heights, increasing minimum size. Does not change parent-layout alignment of the Control.

Theme properties

These are Theme resource keys, not C# properties. Use the matching Control GetTheme…() and AddTheme…Override() methods for each value type.

Key and typeDescription
font_color
Color

Default text Color of the Button.

Default: Color(0.875, 0.875, 0.875, 1)
font_disabled_color
Color

Text Color used when the Button is disabled.

Default: Color(0.875, 0.875, 0.875, 0.5)
font_focus_color
Color

Text Color used when the Button is focused. Only replaces the normal text color of the button. Disabled, hovered, and pressed states take precedence over this color.

Default: Color(0.95, 0.95, 0.95, 1)
font_hover_color
Color

Text Color used when the Button is being hovered.

Default: Color(0.95, 0.95, 0.95, 1)
font_hover_pressed_color
Color

Text Color used when the Button is being hovered and pressed.

Default: Color(1, 1, 1, 1)
font_outline_color
Color

The tint of text outline of the Button.

Default: Color(0, 0, 0, 1)
font_pressed_color
Color

Text Color used when the Button is being pressed.

Default: Color(1, 1, 1, 1)
icon_disabled_color
Color

Icon modulate Color used when the Button is disabled.

Default: Color(1, 1, 1, 0.4)
icon_focus_color
Color

Icon modulate Color used when the Button is focused. Only replaces the normal modulate color of the button. Disabled, hovered, and pressed states take precedence over this color.

Default: Color(1, 1, 1, 1)
icon_hover_color
Color

Icon modulate Color used when the Button is being hovered.

Default: Color(1, 1, 1, 1)
icon_hover_pressed_color
Color

Icon modulate Color used when the Button is being hovered and pressed.

Default: Color(1, 1, 1, 1)
icon_normal_color
Color

Default icon modulate Color of the Button.

Default: Color(1, 1, 1, 1)
icon_pressed_color
Color

Icon modulate Color used when the Button is being pressed.

Default: Color(1, 1, 1, 1)
align_to_largest_stylebox
int

This constant acts as a boolean. If true, the minimum size of the button and text/icon alignment is always based on the largest stylebox margins, otherwise it's based on the current button state stylebox margins.

Default: 0
h_separation
int

The horizontal space between Button's icon and text. Negative values will be treated as 0 when used.

Default: 4
icon_max_width
int

The maximum allowed width of the Button's icon. This limit is applied on top of the default size of the icon, or its expanded size if Button.ExpandIcon is true. The height is adjusted according to the icon's ratio. If the button has additional icons (e.g. CheckBox), they will also be limited.

Default: 0
line_spacing
int

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.

Default: 0
outline_size
int

The size of the text outline. Note: If using a font with FontFile.MultichannelSignedDistanceField enabled, its FontFile.MsdfPixelRange must be set to at least twice the value of Button.outline_size for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.

Default: 0
font
Font

Font of the Button's text.

font_size
int

Font size of the Button's text.

icon
Texture2D

Default icon for the Button. Appears only if Button.Icon is not assigned.

disabled
StyleBox

StyleBox used when the Button is disabled.

disabled_mirrored
StyleBox

StyleBox used when the Button is disabled (for right-to-left layouts).

focus
StyleBox

StyleBox used when the Button is focused. The Button.focus StyleBox is displayed over the base StyleBox, so a partially transparent StyleBox should be used to ensure the base StyleBox remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.

hover
StyleBox

StyleBox used when the Button is being hovered.

hover_mirrored
StyleBox

StyleBox used when the Button is being hovered (for right-to-left layouts).

hover_pressed
StyleBox

StyleBox used when the Button is being pressed and hovered at the same time.

hover_pressed_mirrored
StyleBox

StyleBox used when the Button is being pressed and hovered at the same time (for right-to-left layouts).

normal
StyleBox

Default StyleBox for the Button.

normal_mirrored
StyleBox

Default StyleBox for the Button (for right-to-left layouts).

pressed
StyleBox

StyleBox used when the Button is being pressed.

pressed_mirrored
StyleBox

StyleBox used when the Button is being pressed (for right-to-left layouts).

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.