Button

package
v0.0.0-...-c858641 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 29 Imported by: 0

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

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 Any

type Any interface {
	gd.IsClass
	AsButton() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]) AsButton

func (self *Extension[T]) AsButton() Instance

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Control.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Button

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 New

func New() Instance

func (Instance) Alignment

func (self Instance) Alignment() GUI.HorizontalAlignment

func (Instance) AsBaseButton

func (self Instance) AsBaseButton() BaseButton.Instance

func (Instance) AsButton

func (self Instance) AsButton() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AutowrapMode

func (self Instance) AutowrapMode() TextServer.AutowrapMode

func (Instance) ClipText

func (self Instance) ClipText() bool

func (Instance) ExpandIcon

func (self Instance) ExpandIcon() bool

func (Instance) Flat

func (self Instance) Flat() bool

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Icon

func (self Instance) Icon() Texture2D.Instance

func (Instance) IconAlignment

func (self Instance) IconAlignment() GUI.HorizontalAlignment

func (Instance) Language

func (self Instance) Language() string

func (Instance) SetAlignment

func (self Instance) SetAlignment(value GUI.HorizontalAlignment)

func (Instance) SetAutowrapMode

func (self Instance) SetAutowrapMode(value TextServer.AutowrapMode)

func (Instance) SetClipText

func (self Instance) SetClipText(value bool)

func (Instance) SetExpandIcon

func (self Instance) SetExpandIcon(value bool)

func (Instance) SetFlat

func (self Instance) SetFlat(value bool)

func (Instance) SetIcon

func (self Instance) SetIcon(value Texture2D.Instance)

func (Instance) SetIconAlignment

func (self Instance) SetIconAlignment(value GUI.HorizontalAlignment)

func (Instance) SetLanguage

func (self Instance) SetLanguage(value string)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetText

func (self Instance) SetText(value string)

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) Text

func (self Instance) Text() string

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

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL