Documentation
¶
Overview ¶
graphics.gd/classdb/Button is the standard themed button. It can contain text and an icon, and it will display them according to the current graphics.gd/classdb/Theme.
Example: Create a button and connect a method that will be called when the button is pressed:
package main import ( "graphics.gd/classdb/Button" "graphics.gd/classdb/Node" ) type ExampleForButton struct { Node.Extension[ExampleForButton] } func (eg *ExampleForButton) Ready() { button := Button.New() button.SetText("Click me") button.AsBaseButton().OnPressed(func() { print("Hello world!") }) eg.AsNode().AddChild(button.AsNode()) }
See also graphics.gd/classdb/BaseButton which contains common properties and methods associated with this node.
Note: Buttons do not detect touch input and therefore don't support multitouch, since mouse emulation can only press one button at a given time. Use graphics.gd/classdb/TouchScreenButton for buttons that trigger gameplay movement or actions.
Index ¶
- type Advanced
- type Any
- type Extension
- func (self *Extension[T]) AsBaseButton() BaseButton.Instance
- func (self *Extension[T]) AsButton() 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
- type ID
- type Instance
- func (self Instance) Alignment() GUI.HorizontalAlignment
- func (self Instance) AsBaseButton() BaseButton.Instance
- func (self Instance) AsButton() 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) AutowrapMode() TextServer.AutowrapMode
- func (self Instance) ClipText() bool
- func (self Instance) ExpandIcon() bool
- func (self Instance) Flat() bool
- func (self Instance) ID() ID
- func (self Instance) Icon() Texture2D.Instance
- func (self Instance) IconAlignment() GUI.HorizontalAlignment
- func (self Instance) Language() string
- func (self Instance) SetAlignment(value GUI.HorizontalAlignment)
- func (self Instance) SetAutowrapMode(value TextServer.AutowrapMode)
- func (self Instance) SetClipText(value bool)
- func (self Instance) SetExpandIcon(value bool)
- func (self Instance) SetFlat(value bool)
- func (self Instance) SetIcon(value Texture2D.Instance)
- func (self Instance) SetIconAlignment(value GUI.HorizontalAlignment)
- func (self Instance) SetLanguage(value string)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetText(value string)
- func (self Instance) SetTextDirection(value Control.TextDirection)
- func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)
- func (self Instance) SetVerticalIconAlignment(value GUI.VerticalAlignment)
- func (self Instance) Text() string
- func (self Instance) TextDirection() Control.TextDirection
- func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior
- func (self Instance) VerticalIconAlignment() GUI.VerticalAlignment
- func (self Instance) Virtual(name string) reflect.Value
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
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 ¶
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) Alignment ¶
func (self Instance) Alignment() GUI.HorizontalAlignment
func (Instance) AsBaseButton ¶
func (self Instance) AsBaseButton() BaseButton.Instance
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AutowrapMode ¶
func (self Instance) AutowrapMode() TextServer.AutowrapMode
func (Instance) ExpandIcon ¶
func (Instance) IconAlignment ¶
func (self Instance) IconAlignment() GUI.HorizontalAlignment
func (Instance) SetAlignment ¶
func (self Instance) SetAlignment(value GUI.HorizontalAlignment)
func (Instance) SetAutowrapMode ¶
func (self Instance) SetAutowrapMode(value TextServer.AutowrapMode)
func (Instance) SetClipText ¶
func (Instance) SetExpandIcon ¶
func (Instance) SetIconAlignment ¶
func (self Instance) SetIconAlignment(value GUI.HorizontalAlignment)
func (Instance) SetLanguage ¶
func (Instance) SetTextDirection ¶
func (self Instance) SetTextDirection(value Control.TextDirection)
func (Instance) SetTextOverrunBehavior ¶
func (self Instance) SetTextOverrunBehavior(value TextServer.OverrunBehavior)
func (Instance) SetVerticalIconAlignment ¶
func (self Instance) SetVerticalIconAlignment(value GUI.VerticalAlignment)
func (Instance) TextDirection ¶
func (self Instance) TextDirection() Control.TextDirection
func (Instance) TextOverrunBehavior ¶
func (self Instance) TextOverrunBehavior() TextServer.OverrunBehavior
func (Instance) VerticalIconAlignment ¶
func (self Instance) VerticalIconAlignment() GUI.VerticalAlignment