BaseButton

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

BaseButton is an abstract base class for GUI buttons. It doesn't display anything by itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionMode

type ActionMode int //gd:BaseButton.ActionMode
const (
	// Require just a press to consider the button clicked.
	ActionModeButtonPress ActionMode = 0
	// Require a press and a subsequent release before considering the button clicked.
	ActionModeButtonRelease ActionMode = 1
)

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
	AsBaseButton() Instance
}

type DrawMode

type DrawMode int //gd:BaseButton.DrawMode
const (
	// The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
	DrawNormal DrawMode = 0
	// The state of buttons are pressed.
	DrawPressed DrawMode = 1
	// The state of buttons are hovered.
	DrawHover DrawMode = 2
	// The state of buttons are disabled.
	DrawDisabled DrawMode = 3
	// The state of buttons are both hovered and pressed.
	DrawHoverPressed DrawMode = 4
)

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]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsBaseButton

func (self *Extension[T]) AsBaseButton() 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 Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.BaseButton

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

func (self Instance) ActionMode() ActionMode

Determines when the button is considered clicked.

func (Instance) AsBaseButton

func (self Instance) AsBaseButton() 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) ButtonMask

func (self Instance) ButtonMask() Input.MouseButtonMask

Binary mask to choose which mouse buttons this button will respond to.

To allow both left-click and right-click, use MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT.

func (Instance) ButtonPressed

func (self Instance) ButtonPressed() bool

If true, the button's state is pressed. Means the button is pressed down or toggled (if ToggleMode is active). Only works if ToggleMode is true.

Note: Changing the value of ButtonPressed will result in OnToggled to be emitted. If you want to change the pressed state without emitting that signal, use SetPressedNoSignal.

func (Instance) Disabled

func (self Instance) Disabled() bool

If true, the button is in disabled state and can't be clicked or toggled.

Note: If the button is disabled while held down, OnButtonUp will be emitted.

func (Instance) GetDrawMode

func (self Instance) GetDrawMode() DrawMode

Returns the visual state used to draw the button. This is useful mainly when implementing your own draw code by either overriding _draw() or connecting to "draw" signal. The visual state of the button is defined by the DrawMode enum.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsHovered

func (self Instance) IsHovered() bool

Returns true if the mouse has entered the button and has not left it yet.

func (Instance) KeepPressedOutside

func (self Instance) KeepPressedOutside() bool

If true, the button stays pressed when moving the cursor outside the button while pressing it.

Note: This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value.

func (Instance) OnButtonDown

func (self Instance) OnButtonDown(cb func(), flags ...Signal.Flags)

Emitted when the button starts being held down.

func (Instance) OnButtonUp

func (self Instance) OnButtonUp(cb func(), flags ...Signal.Flags)

Emitted when the button stops being held down.

func (Instance) OnPressed

func (self Instance) OnPressed(cb func(), flags ...Signal.Flags)

Emitted when the button is toggled or pressed. This is on OnButtonDown if ActionMode is ActionModeButtonPress and on OnButtonUp otherwise.

If you need to know the button's pressed state (and ToggleMode is active), use OnToggled instead.

func (Instance) OnToggled

func (self Instance) OnToggled(cb func(toggled_on bool), flags ...Signal.Flags)

Emitted when the button was just toggled between pressed and normal states (only if ToggleMode is active). The new state is contained in the 'toggled_on' argument.

func (Instance) SetActionMode

func (self Instance) SetActionMode(value ActionMode)

SetActionMode sets the property returned by [GetActionMode].

func (Instance) SetButtonMask

func (self Instance) SetButtonMask(value Input.MouseButtonMask)

SetButtonMask sets the property returned by [GetButtonMask].

func (Instance) SetButtonPressed

func (self Instance) SetButtonPressed(value bool)

SetButtonPressed sets the property returned by [IsPressed].

func (Instance) SetDisabled

func (self Instance) SetDisabled(value bool)

SetDisabled sets the property returned by [IsDisabled].

func (Instance) SetKeepPressedOutside

func (self Instance) SetKeepPressedOutside(value bool)

SetKeepPressedOutside sets the property returned by [IsKeepPressedOutside].

func (*Instance) SetObject

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

func (Instance) SetPressedNoSignal

func (self Instance) SetPressedNoSignal(pressed bool)

Changes the ButtonPressed state of the button, without emitting OnToggled. Use when you just want to change the state of the button without sending the pressed event (e.g. when initializing scene). Only works if ToggleMode is true.

Note: This method doesn't unpress other buttons in ButtonGroup.

func (Instance) SetShortcut

func (self Instance) SetShortcut(value Shortcut.Instance)

SetShortcut sets the property returned by [GetShortcut].

func (Instance) SetShortcutFeedback

func (self Instance) SetShortcutFeedback(value bool)

SetShortcutFeedback sets the property returned by [IsShortcutFeedback].

func (Instance) SetShortcutInTooltip

func (self Instance) SetShortcutInTooltip(value bool)

SetShortcutInTooltip sets the property returned by [IsShortcutInTooltipEnabled].

func (Instance) SetToggleMode

func (self Instance) SetToggleMode(value bool)

SetToggleMode sets the property returned by [IsToggleMode].

func (Instance) Shortcut

func (self Instance) Shortcut() Shortcut.Instance

Shortcut associated to the button.

func (Instance) ShortcutFeedback

func (self Instance) ShortcutFeedback() bool

If true, the button will highlight for a short amount of time when its shortcut is activated. If false and ToggleMode is false, the shortcut will activate without any visual feedback.

func (Instance) ShortcutInTooltip

func (self Instance) ShortcutInTooltip() bool

If true, the button will add information about its shortcut in the tooltip.

Note: This property does nothing when the tooltip control is customized using Control.MakeCustomTooltip.

func (Instance) ToggleMode

func (self Instance) ToggleMode() bool

If true, the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.

func (Instance) Virtual

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

type Interface

type Interface interface {
	// Called when the button is pressed. If you need to know the button's pressed state (and [ToggleMode] is active), use [Toggled] instead.
	//
	// [ToggleMode]: https://pkg.go.dev/graphics.gd/classdb/BaseButton#Instance.ToggleMode
	// [Toggled]: https://pkg.go.dev/graphics.gd/classdb/BaseButton#Interface
	Pressed()
	// Called when the button is toggled (only if [ToggleMode] is active).
	//
	// [ToggleMode]: https://pkg.go.dev/graphics.gd/classdb/BaseButton#Instance.ToggleMode
	Toggled(toggled_on bool)
}

Jump to

Keyboard shortcuts

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