`numinput()` creates a numeric input control.
Creates a numinput object.
| Item | Description |
|---|---|
| Syntax | `numinput()` |
| Arguments | none |
| Returns | numinput object |
Example:
n = numinput().value(10).minmax(0, 100);
Properties are read-only. Use methods to change GUI object state.
| Property | Type | Description |
|---|---|---|
| `position_x` | number | Current x position. |
| `position_y` | number | Current y position. |
| `size_width` | number | Current width. |
| `size_height` | number | Current height. |
| `visible` | boolean | Current visible state. |
| `enabled` | boolean | Current enabled state. |
| `value` | number | Current numeric value. |
| `min` | number | Current minimum. |
| `max` | number | Current maximum. |
| `decimals` | number | Displayed decimal count. |
| `step` | number | Increment/decrement step. |
| `buttons` | boolean | Whether step buttons are visible. |
Returns a display string for the object.
| Item | Description |
|---|---|
| Syntax | `value.to_string()` |
| Arguments | none |
| Returns | string |
Example:
text = value.to_string();
`clone()` is not supported for `numinput`.
Most visible GUI controls support these methods.
Sets the component position in pixels.
| Item | Description |
|---|---|
| Syntax | `component.position(x, y)` |
| Arguments | `x`: x position; `y`: y position |
| Returns | component object |
Example:
label().position(20, 10);
Sets the component size in pixels. Width and height are clamped to at least `1`.
Some container objects, such as `panel()` and `group()`, use `size(-1, -1)` as a special fit-parent mode.
| Item | Description |
|---|---|
| Syntax | `component.size(width, height)` |
| Arguments | `width`: width in pixels; `height`: height in pixels |
| Returns | component object |
Example:
textinput().size(220, 26);
Shows or hides the component.
| Item | Description |
|---|---|
| Syntax | `component.visible(enabled)` |
| Arguments | `enabled`: boolean |
| Returns | component object |
Example:
status.visible(false);
Enables or disables user interaction with the component.
| Item | Description |
|---|---|
| Syntax | `component.enabled(enabled)` |
| Arguments | `enabled`: boolean |
| Returns | component object |
Example:
run_button.enabled(false);
Sets current numeric value. Value is clamped to the current range.
| Item | Description |
|---|---|
| Syntax | `numinput.value(value)` |
| Arguments | `value`: numeric value |
| Returns | numinput object |
Example:
n = numinput().minmax(0, 100).value(25);
Sets allowed numeric range. If `min` is greater than `max`, the values are swapped. The current value is clamped to the new range.
| Item | Description |
|---|---|
| Syntax | `numinput.minmax(min, max)` |
| Arguments | `min`: minimum value; `max`: maximum value |
| Returns | numinput object |
Example:
n = numinput().minmax(0, 100);
Sets allowed numeric range and displayed decimal count. Decimal count is clamped to at least `0`.
| Item | Description |
|---|---|
| Syntax | `numinput.minmax(min, max, decimals)` |
| Arguments | `min`: minimum value; `max`: maximum value; `decimals`: number of decimals |
| Returns | numinput object |
Example:
n = numinput().minmax(0, 100, 2);
Sets increment/decrement step.
| Item | Description |
|---|---|
| Syntax | `numinput.step(value)` |
| Arguments | `value`: step size |
| Returns | numinput object |
Example:
n = numinput().step(0.5);
Shows or hides step buttons.
| Item | Description |
|---|---|
| Syntax | `numinput.buttons(enabled)` |
| Arguments | `enabled`: boolean |
| Returns | numinput object |
Example:
n = numinput().buttons(false);
Increments the value by `step`, clamps it to the current range, and calls the change callback.
| Item | Description |
|---|---|
| Syntax | `numinput.increment()` |
| Arguments | none |
| Returns | numinput object |
Example:
n.increment();
Decrements the value by `step`, clamps it to the current range, and calls the change callback.
| Item | Description |
|---|---|
| Syntax | `numinput.decrement()` |
| Arguments | none |
| Returns | numinput object |
Example:
n.decrement();
Sets a callback called when the value changes.
| Item | Description |
|---|---|
| Syntax | `numinput.on_change(callback)` |
| Arguments | `callback`: callable with one argument, the current numeric value |
| Returns | numinput object |
Example:
function speed_changed(value) { print('speed: ', value); } speed = numinput().on_change(speed_changed);