SpinBox

Inherits: Range < Control < CanvasItem < Node < Object

数值输入文本字段。

描述

SpinBox是一个数字输入文本字段。它允许输入整数和浮点数。

例子:

  1. var spin_box = SpinBox.new()
  2. add_child(spin_box)
  3. var line_edit = spin_box.get_line_edit()
  4. line_edit.context_menu_enabled = false
  5. spin_box.align = LineEdit.ALIGN_RIGHT

上面的代码将创建一个SpinBox,禁用其上的上下文菜单,并将文本对齐方式设置为右对齐。

参阅Range类,以获得更多关于SpinBox的选项。

注意: SpinBox 依赖于底层的LineEdit节点。要为SpinBox的背景设置主题,请为LineEdit添加主题项,并对其进行定制。

属性

Align

align

0

bool

editable

true

String

prefix

“”

String

suffix

“”

方法

void

apply ( )

LineEdit

get_line_edit ( )

主题属性

Texture

updown

属性说明

Default

0

Setter

set_align(value)

Getter

get_align()

设置 SpinBox 的文本对齐方式。


Default

true

Setter

set_editable(value)

Getter

is_editable()

如果 true,则 SpinBox 将是可编辑的。否则,它将是只读的。


Default

“”

Setter

set_prefix(value)

Getter

get_prefix()

SpinBox 的数值前添加指定的 prefix 字符串。


Default

“”

Setter

set_suffix(value)

Getter

get_suffix()

SpinBox 的数值后添加指定的 suffix 字符串。

方法说明

  • void apply ( )

应用此 SpinBox 的当前值。


返回这个SpinBox中的LineEdit实例。你可以用它来访问LineEdit的属性和方法。

警告: 这是一个必要的内部节点,移除和释放它可能会导致崩溃。如果你想隐藏它或它的任何子节点,请使用其 CanvasItem.visible 属性。

Theme Property Descriptions

SpinBox 的上下箭头设置自定义 Texture