Documentation
¶
Overview ¶
TextureButton has the same functionality as Button, except it uses sprites instead of Godot's Theme resource. It is faster to create, but it doesn't support localization like more complex Controls.
See also BaseButton which contains common properties and methods associated with this node.
Note: Setting a texture for the "normal" state (TextureNormal) is recommended. If TextureNormal is not set, the TextureButton will still receive input events and be clickable, but the user will not be able to see it unless they activate another one of its states with a texture assigned (e.g., hover over it to show TextureHover).
Index ¶
- type Advanced
- type Any
- type Extension
- func (self *Extension[T]) AsBaseButton() BaseButton.Instance
- func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
- func (self *Extension[T]) AsControl() Control.Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsTextureButton() Instance
- type ID
- type Instance
- func (self Instance) AsBaseButton() BaseButton.Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsControl() Control.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsTextureButton() Instance
- func (self Instance) FlipH() bool
- func (self Instance) FlipV() bool
- func (self Instance) ID() ID
- func (self Instance) IgnoreTextureSize() bool
- func (self Instance) SetFlipH(value bool)
- func (self Instance) SetFlipV(value bool)
- func (self Instance) SetIgnoreTextureSize(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetStretchMode(value StretchMode)
- func (self Instance) SetTextureClickMask(value BitMap.Instance)
- func (self Instance) SetTextureDisabled(value Texture2D.Instance)
- func (self Instance) SetTextureFocused(value Texture2D.Instance)
- func (self Instance) SetTextureHover(value Texture2D.Instance)
- func (self Instance) SetTextureNormal(value Texture2D.Instance)
- func (self Instance) SetTexturePressed(value Texture2D.Instance)
- func (self Instance) StretchMode() StretchMode
- func (self Instance) TextureClickMask() BitMap.Instance
- func (self Instance) TextureDisabled() Texture2D.Instance
- func (self Instance) TextureFocused() Texture2D.Instance
- func (self Instance) TextureHover() Texture2D.Instance
- func (self Instance) TextureNormal() Texture2D.Instance
- func (self Instance) TexturePressed() Texture2D.Instance
- func (self Instance) Virtual(name string) reflect.Value
- type StretchMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsBaseButton ¶
func (self *Extension[T]) AsBaseButton() BaseButton.Instance
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
func (*Extension[T]) AsTextureButton ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.TextureButton
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsBaseButton ¶
func (self Instance) AsBaseButton() BaseButton.Instance
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsTextureButton ¶
func (Instance) IgnoreTextureSize ¶
If true, the size of the texture won't be considered for minimum size calculation, so the TextureButton can be shrunk down past the texture size.
func (Instance) SetIgnoreTextureSize ¶
SetIgnoreTextureSize sets the property returned by [GetIgnoreTextureSize].
func (Instance) SetStretchMode ¶
func (self Instance) SetStretchMode(value StretchMode)
SetStretchMode sets the property returned by [GetStretchMode].
func (Instance) SetTextureClickMask ¶
SetTextureClickMask sets the property returned by [GetClickMask].
func (Instance) SetTextureDisabled ¶
SetTextureDisabled sets the property returned by [GetTextureDisabled].
func (Instance) SetTextureFocused ¶
SetTextureFocused sets the property returned by [GetTextureFocused].
func (Instance) SetTextureHover ¶
SetTextureHover sets the property returned by [GetTextureHover].
func (Instance) SetTextureNormal ¶
SetTextureNormal sets the property returned by [GetTextureNormal].
func (Instance) SetTexturePressed ¶
SetTexturePressed sets the property returned by [GetTexturePressed].
func (Instance) StretchMode ¶
func (self Instance) StretchMode() StretchMode
Controls the texture's behavior when you resize the node's bounding rectangle. See the StretchMode constants for available options.
func (Instance) TextureClickMask ¶
Pure black and white BitMap image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
func (Instance) TextureDisabled ¶
Texture to display when the node is disabled. See BaseButton.Disabled. If not assigned, the TextureButton displays TextureNormal instead.
func (Instance) TextureFocused ¶
Texture to overlay on the base texture when the node has mouse or keyboard focus. Because TextureFocused is displayed on top of the base texture, a partially transparent texture should be used to ensure the base texture remains visible. A texture that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a fully transparent texture of any size. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
func (Instance) TextureHover ¶
Texture to display when the mouse hovers over the node. If not assigned, the TextureButton displays TextureNormal instead when hovered over.
func (Instance) TextureNormal ¶
Texture to display by default, when the node is not in the disabled, hover or pressed state. This texture is still displayed in the focused state, with TextureFocused drawn on top.
func (Instance) TexturePressed ¶
Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the Enter key or if the player presses the BaseButton.Shortcut key. If not assigned, the TextureButton displays TextureHover instead when pressed.
type StretchMode ¶
type StretchMode int //gd:TextureButton.StretchMode
const ( // Scale to fit the node's bounding rectangle. StretchScale StretchMode = 0 // Tile inside the node's bounding rectangle. StretchTile StretchMode = 1 // The texture keeps its original size and stays in the bounding rectangle's top-left corner. StretchKeep StretchMode = 2 // The texture keeps its original size and stays centered in the node's bounding rectangle. StretchKeepCentered StretchMode = 3 // Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio. StretchKeepAspect StretchMode = 4 // Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio. StretchKeepAspectCentered StretchMode = 5 // Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits. StretchKeepAspectCovered StretchMode = 6 )