1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/docs/widgets/extra/spinbox.md

59 lines
2.1 KiB
Markdown
Raw Normal View History

```eval_rst
.. include:: /header.rst
2021-05-19 13:51:22 +02:00
:github_url: |github_link_base|/widgets/extra/spinbox.md
```
# Spinbox (lv_spinbox)
## Overview
The Spinbox contains a number as text which can be increased or decreased by *Keys* or API functions.
2021-05-19 13:51:22 +02:00
Under the hood the Spinbox is a modified [Text area](/widgets/core/textarea).
## Parts and Styles
2021-05-19 13:51:22 +02:00
The parts of the Spinbox are identiacl to the [Text area](/widgets/core/textarea).
2021-05-19 13:51:22 +02:00
### Value, range and step
`lv_spinbox_set_value(spinbox, 1234)` sets a new value on the Spinbox.
2021-05-19 13:51:22 +02:00
`lv_spinbox_increment(spinbox)` and `lv_spinbox_decrement(spinbox)` increments/decrements the value of the Spinbox according to the currently selected digit.
2021-05-19 13:51:22 +02:00
`lv_spinbox_set_range(spinbox, -1000, 2500)` sets a range. If the value is changed by `lv_spinbox_set_value`, by *Keys*,`lv_spinbox_increment/decrement` this range will be respected.
2021-05-19 13:51:22 +02:00
`lv_spinbox_set_step(spinbox, 100)` sets which digits to change on increment/decrement. Only 10^n values values can be set, and not for example 3.
2021-05-19 13:51:22 +02:00
### Format
2021-05-19 13:51:22 +02:00
`lv_spinbox_set_digit_format(spinbox, digit_count, separator_position)` sets the number format. `digit_count` is the number of digit excluding the decimal separator and the sign.
`separator_position` is the number of digit before the decimal point. If 0, decimal point is not
2021-05-19 13:51:22 +02:00
### Rollover
`lv_spinbox_set_rollover(spinbox, true/false)` enables/disabled rolloiver mode. If the minimum or maximum values is reached with rollover the value will change to the other limit.
If not enabled the value will be reamain at the minimum or maximum value.
## Events
2021-05-19 13:51:22 +02:00
- `LV_EVENT_VALUE_CHANGED` Sent when the value has changed.
Learn more about [Events](/overview/event).
## Keys
2021-05-19 13:51:22 +02:00
- `LV_KEY_LEFT/RIGHT` With *Keypad* move the cursor left/right. With *Encoder* decrement/increment the selected digit.
- `LV_KEY_UP/DOWN` With *Keypad* and *Encoder* increment/decrement the value.
- `LV_KEY_ENTER` With *Encoder* got the net digit. Jump to the first after the last.
## Example
```eval_rst
2021-05-19 13:51:22 +02:00
.. include:: ../../../examples/widgets/spinbox/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_spinbox.h
:project: lvgl
```
## Example