1.. _lv_spinbox: 2 3==================== 4Spinbox (lv_spinbox) 5==================== 6 7 8Overview 9******** 10 11Spinbox contains an integer displayed as a decimal number with a possible fixed 12decimal point position and a configurable number of digits. The value can be 13increased or decreased by *Keys* or API functions. Under the hood Spinbox is a 14:ref:`lv_textarea` with behaviors extended to enable a numeric value 15to be viewed and modified with configurable constraints. 16 17 18 19.. _lv_spinbox_parts_and_styles: 20 21Parts and Styles 22**************** 23 24Spinbox's parts are identical to those of :ref:`Text Area <lv_textarea_parts_and_styles>`. 25 26Value, range and step 27--------------------- 28 29- :cpp:expr:`lv_spinbox_set_value(spinbox, 1234)` sets a new value for the Spinbox. 30- :cpp:expr:`lv_spinbox_increment(spinbox)` and :cpp:expr:`lv_spinbox_decrement(spinbox)` 31 increments/decrements the value of the Spinbox according to the currently-selected digit. 32- :cpp:expr:`lv_spinbox_set_range(spinbox, -1000, 2500)` sets its range. If the 33 value is changed by :cpp:expr:`lv_spinbox_set_value(spinbox)`, by *Keys*, 34 by :cpp:expr:`lv_spinbox_increment(spinbox)` or :cpp:expr:`lv_spinbox_decrement(spinbox)` 35 this range will be respected. 36- :cpp:expr:`lv_spinbox_set_step(spinbox, 100)` sets which digit to change on 37 increment/decrement. Only multiples of ten can be set. 38- :cpp:expr:`lv_spinbox_set_cursor_pos(spinbox, 1)` sets the cursor to a specific 39 digit to change on increment/decrement. Position '0' sets the cursor to 40 the least significant digit. 41 42If an encoder is used as input device, the selected digit is shifted to 43the right by default whenever the encoder button is clicked. To change this behaviour to shifting 44to the left, the :cpp:expr:`lv_spinbox_set_digit_step_direction(spinbox, LV_DIR_LEFT)` can be used 45 46Format 47------ 48 49:cpp:expr:`lv_spinbox_set_digit_format(spinbox, digit_count, separator_position)` 50sets the number format. ``digit_count`` is the total number of digits to display. 51``separator_position`` is the number of leading digits before the decimal point. 52Pass 0 for ``separator_position`` to display no decimal point. 53 54Rollover 55-------- 56 57:cpp:expr:`lv_spinbox_set_rollover(spinbox, true/false)` enables/disabled 58rollover mode. If either the minimum or maximum value is reached with 59rollover enabled, and the user attempts to continue changing the value in 60the same direction, the value will change to the other limit. If rollover 61is disabled the value will stop at the minimum or maximum value. 62 63 64 65.. _lv_spinbox_events: 66 67Events 68****** 69 70- :cpp:enumerator:`LV_EVENT_VALUE_CHANGED` Sent when value has changed. 71 72.. admonition:: Further Reading 73 74 :ref:`Textarea Events <lv_textarea_events>`. 75 76 Learn more about :ref:`lv_obj_events` emitted by all Widgets. 77 78 Learn more about :ref:`events`. 79 80 81 82.. _lv_spinbox_keys: 83 84Keys 85**** 86 87- ``LV_KEY_LEFT/RIGHT`` With *Keypad* move the cursor left/right. With 88 *Encoder* decrement/increment the selected digit. 89- ``LV_KEY_UP/DOWN`` With *Keypad* and *Encoder* increment/decrement 90 the value. 91- :cpp:enumerator:`LV_KEY_ENTER` With *Encoder*, move focus to next digit. If focus 92 is on last digit, focus moves to first digit. 93 94.. admonition:: Further Reading 95 96 Learn more about :ref:`indev_keys`. 97 98 99 100.. _lv_spinbox_example: 101 102Example 103******* 104 105.. include:: ../../examples/widgets/spinbox/index.rst 106 107 108 109.. _lv_spinbox_api: 110 111API 112*** 113