TextureButton
Button with state textures and an optional click mask.
TextureButton inherits Press, Pressed, ToggleMode and ButtonGroup from BaseButton, but draws assigned textures rather than ordinary Button theme visuals. Set TextureNormal and optionally TexturePressed, TextureHover, TextureDisabled and TextureFocused. Prefer matching dimensions and alignment across states, especially with a click mask.
StretchMode defaults to Keep: the texture draws at source size. Changing Size alone does not stretch it. For a scalable button, set IgnoreTextureSize = true and choose StretchMode: Scale stretches each axis, KeepAspectCentered fits and centers, KeepAspectCovered fills with a central crop. IgnoreTextureSize removes intrinsic minimum size while retaining CustomMinimumSize and parent constraints.
With IgnoreTextureSize = false, minimum size comes from the first available source: TextureNormal, otherwise TexturePressed, otherwise TextureHover, otherwise TextureClickMask. It is not the maximum of all state sizes. TextureDisabled and TextureFocused do not supply minimum size. If only a focus texture is used, size the control explicitly.
Pressed appearance falls back from missing TexturePressed to Hover, then Normal. Disabled without its own texture uses Normal. TextureFocused draws over the current state when focused; it is a separate overlay rather than a universal replacement for the normal texture. A missing texture can leave a state without drawing while BaseButton behavior remains active.
TextureClickMask is a separate Bitmap: true accepts hits and false excludes them. TextureNormal transparency does not automatically create a mask. Scaling and cropping use geometry calculated during drawing. Current mask hit testing does not apply FlipH/FlipV: supply a separately mirrored mask for asymmetric shapes or avoid flipping the image.
Textures and Bitmap are shared resources. Texture changes are observed; edits to an assigned Bitmap do not have the same automatic sizing connection. After changing mask dimensions, explicitly call UpdateMinimumSize and QueueRedraw or assign a new resource. Use a separate child element for text; TextureButton does not provide Text.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
TextureButtonConstructor
public TextureButton();Creates a button without textures or a mask: StretchMode = Keep, IgnoreTextureSize = false, flips off. Activation follows BaseButton.
Properties10
FlipHProperty
public bool FlipH { get; set; }Mirror texture drawing horizontally, default false. Does not edit the resource; current TextureClickMask testing does not apply this flip.
FlipVProperty
public bool FlipV { get; set; }Mirror texture drawing vertically, default false. Does not edit the resource; asymmetric click masks require a separately matching shape.
IgnoreTextureSizeProperty
public bool IgnoreTextureSize { get; set; }Ignore the main texture/mask-derived minimum, default false. Does not select scaling behavior or remove CustomMinimumSize.
StretchModeProperty
public TextureButton.StretchModeEnum StretchMode { get; set; }Drawing mode, default Keep. Scale stretches, Tile repeats, Keep/KeepCentered retain source size, KeepAspect variants retain proportions. Separately enable IgnoreTextureSize to shrink below intrinsic minimum.
TextureClickMaskProperty
public Bitmap TextureClickMask { get; set; }Shared hit Bitmap rather than Texture2D. true accepts a point and false excludes it; image alpha is not automatically used. Current hit testing does not mirror the mask for FlipH/FlipV. Resizing it requires explicit minimum/redraw refresh.
TextureDisabledProperty
public Texture2D TextureDisabled { get; set; }Shared disabled-state Texture2D, or null. Falls back to Normal. Does not supply Control minimum or enable Disabled itself.
TextureFocusedProperty
public Texture2D TextureFocused { get; set; }Shared focus-overlay Texture2D, or null. Draws over the state; can be the sole image when others are absent. Does not supply Control minimum.
TextureHoverProperty
public Texture2D TextureHover { get; set; }Shared hover Texture2D, or null. Supplies minimum only without Normal and Pressed; absent hover can use Normal or a selected Pressed state.
TextureNormalProperty
public Texture2D TextureNormal { get; set; }Base shared Texture2D, or null. First priority for minimum size even when other states are larger.
TexturePressedProperty
public Texture2D TexturePressed { get; set; }Shared pressed-state Texture2D, or null. Falls back to Hover then Normal. Second minimum-size priority after Normal.
Methods20
GetClickMaskBitmap
public Bitmap GetClickMask();Shared hit Bitmap rather than Texture2D. true accepts a point and false excludes it; image alpha is not automatically used. Current hit testing does not mirror the mask for FlipH/FlipV. Resizing it requires explicit minimum/redraw refresh.
BitmapShared Bitmap, or null.
GetIgnoreTextureSizebool
public bool GetIgnoreTextureSize();Ignore the main texture/mask-derived minimum, default false. Does not select scaling behavior or remove CustomMinimumSize.
booltrue when intrinsic texture minimum is ignored.
GetStretchModeTextureButton.StretchModeEnum
public TextureButton.StretchModeEnum GetStretchMode();Drawing mode, default Keep. Scale stretches, Tile repeats, Keep/KeepCentered retain source size, KeepAspect variants retain proportions. Separately enable IgnoreTextureSize to shrink below intrinsic minimum.
TextureButton.StretchModeEnumSelected TextureButton.StretchModeEnum.
GetTextureDisabledTexture2D
public Texture2D GetTextureDisabled();Shared disabled-state Texture2D, or null. Falls back to Normal. Does not supply Control minimum or enable Disabled itself.
Texture2DExplicit shared Texture2D for this state, or null; not the selected fallback.
GetTextureFocusedTexture2D
public Texture2D GetTextureFocused();Shared focus-overlay Texture2D, or null. Draws over the state; can be the sole image when others are absent. Does not supply Control minimum.
Texture2DExplicit shared Texture2D for this state, or null; not the selected fallback.
GetTextureHoverTexture2D
public Texture2D GetTextureHover();Shared hover Texture2D, or null. Supplies minimum only without Normal and Pressed; absent hover can use Normal or a selected Pressed state.
Texture2DExplicit shared Texture2D for this state, or null; not the selected fallback.
GetTextureNormalTexture2D
public Texture2D GetTextureNormal();Base shared Texture2D, or null. First priority for minimum size even when other states are larger.
Texture2DExplicit shared Texture2D for this state, or null; not the selected fallback.
GetTexturePressedTexture2D
public Texture2D GetTexturePressed();Shared pressed-state Texture2D, or null. Falls back to Hover then Normal. Second minimum-size priority after Normal.
Texture2DExplicit shared Texture2D for this state, or null; not the selected fallback.
IsFlippedHbool
public bool IsFlippedH();Mirror texture drawing horizontally, default false. Does not edit the resource; current TextureClickMask testing does not apply this flip.
booltrue for horizontal drawing flip.
IsFlippedVbool
public bool IsFlippedV();Mirror texture drawing vertically, default false. Does not edit the resource; asymmetric click masks require a separately matching shape.
booltrue for vertical drawing flip.
SetClickMaskvoid
public void SetClickMask(Bitmap mask);Shared hit Bitmap rather than Texture2D. true accepts a point and false excludes it; image alpha is not automatically used. Current hit testing does not mirror the mask for FlipH/FlipV. Resizing it requires explicit minimum/redraw refresh.
| Name | Type | Default |
|---|---|---|
mask | Bitmap | — |
maskShared hit Bitmap rather than Texture2D. true accepts a point and false excludes it; image alpha is not automatically used. Current hit testing does not mirror the mask for FlipH/FlipV. Resizing it requires explicit minimum/redraw refresh.
SetFlipHvoid
public void SetFlipH(bool enable);Mirror texture drawing horizontally, default false. Does not edit the resource; current TextureClickMask testing does not apply this flip.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableMirror texture drawing horizontally, default false. Does not edit the resource; current TextureClickMask testing does not apply this flip.
SetFlipVvoid
public void SetFlipV(bool enable);Mirror texture drawing vertically, default false. Does not edit the resource; asymmetric click masks require a separately matching shape.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableMirror texture drawing vertically, default false. Does not edit the resource; asymmetric click masks require a separately matching shape.
SetIgnoreTextureSizevoid
public void SetIgnoreTextureSize(bool ignore);Ignore the main texture/mask-derived minimum, default false. Does not select scaling behavior or remove CustomMinimumSize.
| Name | Type | Default |
|---|---|---|
ignore | bool | — |
ignoreIgnore the main texture/mask-derived minimum, default false. Does not select scaling behavior or remove CustomMinimumSize.
SetStretchModevoid
public void SetStretchMode(TextureButton.StretchModeEnum mode);Drawing mode, default Keep. Scale stretches, Tile repeats, Keep/KeepCentered retain source size, KeepAspect variants retain proportions. Separately enable IgnoreTextureSize to shrink below intrinsic minimum.
| Name | Type | Default |
|---|---|---|
mode | TextureButton.StretchModeEnum | — |
modeDrawing mode, default Keep. Scale stretches, Tile repeats, Keep/KeepCentered retain source size, KeepAspect variants retain proportions. Separately enable IgnoreTextureSize to shrink below intrinsic minimum.
SetTextureDisabledvoid
public void SetTextureDisabled(Texture2D texture);Shared disabled-state Texture2D, or null. Falls back to Normal. Does not supply Control minimum or enable Disabled itself.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureShared disabled-state Texture2D, or null. Falls back to Normal. Does not supply Control minimum or enable Disabled itself.
SetTextureFocusedvoid
public void SetTextureFocused(Texture2D texture);Shared focus-overlay Texture2D, or null. Draws over the state; can be the sole image when others are absent. Does not supply Control minimum.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureShared focus-overlay Texture2D, or null. Draws over the state; can be the sole image when others are absent. Does not supply Control minimum.
SetTextureHovervoid
public void SetTextureHover(Texture2D texture);Shared hover Texture2D, or null. Supplies minimum only without Normal and Pressed; absent hover can use Normal or a selected Pressed state.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureShared hover Texture2D, or null. Supplies minimum only without Normal and Pressed; absent hover can use Normal or a selected Pressed state.
SetTextureNormalvoid
public void SetTextureNormal(Texture2D texture);Base shared Texture2D, or null. First priority for minimum size even when other states are larger.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureBase shared Texture2D, or null. First priority for minimum size even when other states are larger.
SetTexturePressedvoid
public void SetTexturePressed(Texture2D texture);Shared pressed-state Texture2D, or null. Falls back to Hover then Normal. Second minimum-size priority after Normal.
| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
textureShared pressed-state Texture2D, or null. Falls back to Hover then Normal. Second minimum-size priority after Normal.
TextureButton.StretchModeEnum
| Value | Description |
|---|---|
Keep = 2 | The texture keeps its original size and stays in the bounding rectangle's top-left corner. |
KeepAspect = 4 | Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio. |
KeepAspectCentered = 5 | Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio. |
KeepAspectCovered = 6 | Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits. |
KeepCentered = 3 | The texture keeps its original size and stays centered in the node's bounding rectangle. |
Scale = 0 | Scale to fit the node's bounding rectangle. |
Tile = 1 | Tile inside the node's bounding rectangle. |