Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
SpinBox
Успадковує: Range < Control < CanvasItem < Node < Object
Поле введення для чисел.
Опис
SpinBox is a numerical input text field. It allows entering integers and floating-point numbers. The SpinBox also has up and down buttons that can be clicked to increase or decrease the value. The value can also be changed by dragging the mouse up or down over the SpinBox's arrows.
Additionally, mathematical expressions can be entered. These are evaluated when the user presses Enter while editing the SpinBox's text field. This uses the Expression class to parse and evaluate the expression. The result of the expression is then set as the value of the 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 SpinBox, disable its context menu and set its text alignment to right.
var spin_box = SpinBox.new()
add_child(spin_box)
var line_edit = spin_box.get_line_edit()
line_edit.context_menu_enabled = false
spin_box.horizontal_alignment = LineEdit.HORIZONTAL_ALIGNMENT_RIGHT
var spinBox = new SpinBox();
AddChild(spinBox);
var lineEdit = spinBox.GetLineEdit();
lineEdit.ContextMenuEnabled = false;
spinBox.AlignHorizontal = LineEdit.HorizontalAlignEnum.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 and audio feedback on its text field, add theme items for LineEdit and customize them. The LineEdit has the SpinBoxInnerLineEdit theme variation, so that you can give it a distinct appearance from regular LineEdits.
Note: If you want to implement drag and drop for the underlying LineEdit, you can use Control.set_drag_forwarding() on the node returned by get_line_edit().
Властивості
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
BitField[SizeFlags] |
size_flags_vertical |
|
step |
|
|
|
||
|
Методи
void |
apply() |
Властивості теми
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Описи властивостей
HorizontalAlignment alignment = 0 🔗
void set_horizontal_alignment(value: HorizontalAlignment)
HorizontalAlignment get_horizontal_alignment()
Зміна вирівнювання основи LineEdit.
bool custom_arrow_round = false 🔗
Якщо true, значення буде округлено до числа, кратного custom_arrow_step під час взаємодії з кнопками зі стрілками. В іншому випадку значення збільшується на custom_arrow_step, а потім округлюється відповідно до Range.step.
float custom_arrow_step = 0.0 🔗
Якщо не 0, встановлює крок під час взаємодії з кнопками зі стрілками SpinBox.
Примітка: Range.value все одно буде округлено до кратного Range.step.
Якщо true, то SpinBox буде редаговано. В іншому випадку це буде читати тільки.
The formatting of the displayed numeric value, using the same rules as String's % operator (see GDScript format strings). If empty, the value is displayed with no special formatting. If the format string is invalid, the SpinBox will display "<Invalid>", with the error message available as a configuration warning.
The following format strings can be used as examples:
"(%s)"displays as a number in parentheses (e.g.(6.9))."%d ms"displays as an integer with milliseconds unit (e.g.420 ms)."%0.2f%%"displays as a percentage, with 2 decimal places of precision (e.g.21.37%).
AutoTranslateMode format_auto_translate_mode = 2 🔗
void set_format_auto_translate_mode(value: AutoTranslateMode)
AutoTranslateMode get_format_auto_translate_mode()
Auto-translation mode for the format. Useful when the format has a word that can be translated.
Plural version of format. Used only if format is not empty and format_auto_translate_mode is not disabled. If either format or this contain %s the other must also use it. See also Object.tr_n().
Застаріло: Use format instead.
Adds the specified prefix string before the numerical value of the SpinBox. This is used only if format is empty.
bool select_all_on_focus = false 🔗
Якщо true, SpinBox вибере весь текст, коли LineEdit отримує фокус. Натискання стрілок вгору і вниз не запускати цю поведінку.
Застаріло: Use format instead.
Adds the specified suffix string after the numerical value of the SpinBox. This is used only if format is empty.
bool update_on_text_changed = false 🔗
Встановлює значення Range для цього SpinBox, коли текст LineEdit змінюється замість надсилається. Див. LineEdit.text_changed та LineEdit.text_submitted.
Примітка: Якщо встановлено значення true, це заважатиме введенню математичних виразів у SpinBox. SpinBox намагатиметься обчислити вираз під час введення, що означає, що такі символи, як завершальний +, негайно видаляються обчислюваним виразом.
Описи методів
void apply() 🔗
Застосовує поточне значення цього SpinBox. Це еквівалентно натисканню Enter під час редагування LineEdit, що використовується SpinBox. Це призведе до генерації LineEdit.text_submitted та обчислення поточного виразу, що міститься в ньому.
Повернення екземпляра LineEdit з цього SpinBox. Ви можете використовувати його для доступу та методів LineEdit.
Попередження: Це необхідний внутрішній вузол, видаляючи і звільняючи його може призвести до аварії. Якщо ви хочете приховати його або будь-який з своїх дітей, скористайтеся їх CanvasItem.pic.
Описи тематичної нерухомості
Color down_disabled_icon_modulate = Color(0.875, 0.875, 0.875, 0.5) 🔗
Колір модуляції піктограми кнопки вниз, коли кнопка вимкнена.
Color down_hover_icon_modulate = Color(0.95, 0.95, 0.95, 1) 🔗
Колір модуляції значка кнопки вниз, коли на кнопку наведено курсор.
Color down_icon_modulate = Color(0.875, 0.875, 0.875, 1) 🔗
Колір модуляції значка кнопки вниз.
Color down_pressed_icon_modulate = Color(0.95, 0.95, 0.95, 1) 🔗
Колір модуляції піктограми кнопки вниз, коли кнопка натиснута.
Color up_disabled_icon_modulate = Color(0.875, 0.875, 0.875, 0.5) 🔗
Колір модуляції значка кнопки вгору, коли кнопку вимкнено.
Color up_hover_icon_modulate = Color(0.95, 0.95, 0.95, 1) 🔗
Колір модуляції значка кнопки вгору, коли на кнопку наведено курсор.
Color up_icon_modulate = Color(0.875, 0.875, 0.875, 1) 🔗
Колір модуляції значка кнопки вгору.
Color up_pressed_icon_modulate = Color(0.95, 0.95, 0.95, 1) 🔗
Колір модуляції піктограми кнопки вгору, коли кнопка натискається.
int buttons_vertical_separation = 0 🔗
Вертикальна роздільність між кнопками вгору та вниз.
Ширина кнопок вгору та вниз. Якщо менший за будь-який набір піктограм на кнопках, відповідний значок може перекривати сусідні елементи. Якщо менше 0, ширина автоматично регулюється відповідно до розміру значка.
int field_and_buttons_separation = 2 🔗
Ширина горизонтального розділення між полем введення тексту (LineEdit) і кнопками.
The maximum allowed width of the SpinBox's up and down icons. The height is adjusted according to the icon's ratio.
int set_min_buttons_width_from_icons = 1 🔗
Якщо не 0, мінімальна ширина кнопки відповідає найширшій із усіх піктограм, установлених на цих кнопках, навіть якщо buttons_width менше.
Піктограма кнопки вниз, відображається посередині кнопки вниз (зменшується значення).
Значок кнопки вниз, коли кнопку вимкнено.
Значок кнопки вниз, коли на кнопку наведено курсор.
Значок кнопки вниз, коли кнопка натиснута.
Піктограма кнопки вгору, відображається посередині кнопки вгору (збільшення значення).
Значок кнопки вгору, коли кнопку вимкнено.
Значок кнопки вгору, коли на кнопку наведено курсор.
Значок кнопки вгору під час натискання кнопки.
Єдина текстура, що представляє значки кнопок «вгору» та «вниз». Вона відображається посередині кнопок і не змінюється під час взаємодії. Якщо призначено коректний значок, він замінить up та down.
AudioStream focus_sound 🔗
Played when this SpinBox receives keyboard or gamepad-induced focus. Mouse or touch-induced focus does not play a focus sound.
AudioStream pressed_disabled_sound 🔗
Played when the up or down button is pressed while the SpinBox is disabled due to editable being false.
AudioStream pressed_sound 🔗
Played when the up or down button is pressed.
Стиль тла кнопки вниз.
StyleBox down_background_disabled 🔗
Стиль тла кнопки вниз, коли вимкнено.
StyleBox down_background_hovered 🔗
Стиль тла кнопки вниз під час наведення.
StyleBox down_background_pressed 🔗
Стиль тла кнопки вниз під час натискання.
StyleBox field_and_buttons_separator 🔗
StyleBox намальовано в місці, яке займає розділення між полем введення та кнопками.
Стиль тла кнопки вгору.
StyleBox up_background_disabled 🔗
Стиль тла кнопки вгору, коли вимкнено.
StyleBox up_background_hovered 🔗
Стиль тла кнопки вгору під час наведення.
StyleBox up_background_pressed 🔗
Стиль тла кнопки вгору під час натискання.
StyleBox up_down_buttons_separator 🔗
StyleBox намальовано в місці, яке займає роздільник між кнопками вгору та вниз.