Class SpinBox
- Namespace
- Godot
- Assembly
- GodotSharp.dll
SpinBox is a numerical input text field. It allows entering integers and floating point numbers.
Example:
var spinBox = new SpinBox();
AddChild(spinBox);
var lineEdit = spinBox.GetLineEdit();
lineEdit.ContextMenuEnabled = false;
spinBox.AlignHorizontal = LineEdit.HorizontalAlignEnum.Right;
The above code will create a SpinBox, disable context menu on it and set the text alignment to right.
See Range class for more options over the SpinBox.
Note: With the 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: SpinBox relies on an underlying LineEdit node. To theme a SpinBox's background, add theme items for LineEdit and customize them.
Note: If you want to implement drag and drop for the underlying LineEdit, you can use SetDragForwarding(Callable, Callable, Callable) on the node returned by GetLineEdit().
public class SpinBox : Range, IDisposable
- Inheritance
-
SpinBox
- Implements
- Inherited Members
Constructors
SpinBox()
public SpinBox()
Properties
Alignment
Changes the alignment of the underlying LineEdit.
public HorizontalAlignment Alignment { get; set; }
Property Value
CustomArrowStep
If not 0
, Value will always be rounded to a multiple of CustomArrowStep when interacting with the arrow buttons of the SpinBox.
public double CustomArrowStep { get; set; }
Property Value
Editable
If true
, the SpinBox will be editable. Otherwise, it will be read only.
public bool Editable { get; set; }
Property Value
Prefix
Adds the specified prefix string before the numerical value of the SpinBox.
public string Prefix { get; set; }
Property Value
SelectAllOnFocus
If true
, the SpinBox will select the whole text when the LineEdit gains focus. Clicking the up and down arrows won't trigger this behavior.
public bool SelectAllOnFocus { get; set; }
Property Value
Suffix
Adds the specified suffix string after the numerical value of the SpinBox.
public string Suffix { get; set; }
Property Value
UpdateOnTextChanged
Sets the value of the Range for this SpinBox when the LineEdit text is changed instead of submitted. See TextChanged and TextSubmitted.
public bool UpdateOnTextChanged { get; set; }
Property Value
Methods
Apply()
Applies the current value of this SpinBox.
public void Apply()
GetLineEdit()
Returns the LineEdit instance from this SpinBox. You can use it to access properties and methods of 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 Visible property.
public LineEdit GetLineEdit()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.