SpinBox

package
v0.0.0-...-535787f Latest Latest
Warning

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

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

Documentation

Overview

graphics.gd/classdb/SpinBox is a numerical input text field. It allows entering integers and floating-point numbers. The graphics.gd/classdb/SpinBox also has up and down buttons that can be clicked increase or decrease the value. The value can also be changed by dragging the mouse up or down over the graphics.gd/classdb/SpinBox's arrows.

Additionally, mathematical expressions can be entered. These are evaluated when the user presses Enter while editing the graphics.gd/classdb/SpinBox's text field. This uses the graphics.gd/classdb/Expression class to parse and evaluate the expression. The result of the expression is then set as the value of the graphics.gd/classdb/SpinBox. Some examples of valid expressions are 5 + 2 * 3, pow(2, 4), and PI + sin(0.5). Expressions are case-sensitive.

Example: Create a graphics.gd/classdb/SpinBox, disable its context menu and set its text alignment to right.

package main

import (
	"graphics.gd/classdb/GUI"
	"graphics.gd/classdb/Node"
	"graphics.gd/classdb/SpinBox"
)

func ExampleSpinBox(parent Node.Instance) {
	var spinBox = SpinBox.New()
	parent.AddChild(spinBox.AsNode())
	var lineEdit = spinBox.GetLineEdit()
	lineEdit.SetContextMenuEnabled(false)
	SpinBox.Advanced(spinBox).SetHorizontalAlignment(GUI.HorizontalAlignmentRight)
}

See graphics.gd/classdb/Range class for more options over the graphics.gd/classdb/SpinBox.

Note: With the graphics.gd/classdb/SpinBox's context menu disabled, you can right-click the bottom half of the spinbox to set the value to its minimum, while right-clicking the top half sets the value to its maximum.

Note: graphics.gd/classdb/SpinBox relies on an underlying graphics.gd/classdb/LineEdit node. To theme a graphics.gd/classdb/SpinBox's background, add theme items for graphics.gd/classdb/LineEdit and customize them. The graphics.gd/classdb/LineEdit has the SpinBoxInnerLineEdit theme variation, so that you can give it a distinct appearance from regular [graphics.gd/classdb/LineEdit]s.

Note: If you want to implement drag and drop for the underlying graphics.gd/classdb/LineEdit, you can use graphics.gd/classdb/Control.Instance.SetDragForwarding on the node returned by Instance.GetLineEdit.

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
	AsSpinBox() 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]) 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

func (*Extension[T]) AsRange

func (self *Extension[T]) AsRange() Range.Instance

func (*Extension[T]) AsSpinBox

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

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.SpinBox

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

func (self Instance) Apply()

Applies the current value of this graphics.gd/classdb/SpinBox. This is equivalent to pressing Enter while editing the graphics.gd/classdb/LineEdit used by the graphics.gd/classdb/SpinBox. This will cause [Instance.OnLineedit.TextSubmitted] to be emitted and its currently contained expression to be evaluated.

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

func (self Instance) AsRange() Range.Instance

func (Instance) AsSpinBox

func (self Instance) AsSpinBox() Instance

func (Instance) CustomArrowStep

func (self Instance) CustomArrowStep() Float.X

func (Instance) Editable

func (self Instance) Editable() bool

func (Instance) GetLineEdit

func (self Instance) GetLineEdit() LineEdit.Instance

Returns the graphics.gd/classdb/LineEdit instance from this graphics.gd/classdb/SpinBox. You can use it to access properties and methods of graphics.gd/classdb/LineEdit.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their graphics.gd/classdb/CanvasItem.Instance.Visible property.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Prefix

func (self Instance) Prefix() string

func (Instance) SelectAllOnFocus

func (self Instance) SelectAllOnFocus() bool

func (Instance) SetAlignment

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

func (Instance) SetCustomArrowStep

func (self Instance) SetCustomArrowStep(value Float.X)

func (Instance) SetEditable

func (self Instance) SetEditable(value bool)

func (*Instance) SetObject

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

func (Instance) SetPrefix

func (self Instance) SetPrefix(value string)

func (Instance) SetSelectAllOnFocus

func (self Instance) SetSelectAllOnFocus(value bool)

func (Instance) SetSuffix

func (self Instance) SetSuffix(value string)

func (Instance) SetUpdateOnTextChanged

func (self Instance) SetUpdateOnTextChanged(value bool)

func (Instance) Suffix

func (self Instance) Suffix() string

func (Instance) UpdateOnTextChanged

func (self Instance) UpdateOnTextChanged() bool

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