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 ¶
- type Advanced
- type Any
- type Extension
- 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]) AsRange() Range.Instance
- func (self *Extension[T]) AsSpinBox() Instance
- type ID
- type Instance
- func (self Instance) Alignment() GUI.HorizontalAlignment
- func (self Instance) Apply()
- 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) AsRange() Range.Instance
- func (self Instance) AsSpinBox() Instance
- func (self Instance) CustomArrowStep() Float.X
- func (self Instance) Editable() bool
- func (self Instance) GetLineEdit() LineEdit.Instance
- func (self Instance) ID() ID
- func (self Instance) Prefix() string
- func (self Instance) SelectAllOnFocus() bool
- func (self Instance) SetAlignment(value GUI.HorizontalAlignment)
- func (self Instance) SetCustomArrowStep(value Float.X)
- func (self Instance) SetEditable(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPrefix(value string)
- func (self Instance) SetSelectAllOnFocus(value bool)
- func (self Instance) SetSuffix(value string)
- func (self Instance) SetUpdateOnTextChanged(value bool)
- func (self Instance) Suffix() string
- func (self Instance) UpdateOnTextChanged() bool
- 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]) 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) 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) CustomArrowStep ¶
func (Instance) GetLineEdit ¶
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) SelectAllOnFocus ¶
func (Instance) SetAlignment ¶
func (self Instance) SetAlignment(value GUI.HorizontalAlignment)