feat(spinbox ) add function to set cursor to specific position (#2314)
* Spinbox set cursor to specific position (funct.) * changed exp10 to lv_pow(10 * Update lv_spinbox.c resolved indentation * Update spinbox.md Added lv_spinbox_set_pos description Co-authored-by: Sebastian Dyker <sebastian.dyker@walther-systemtechnik.com>
This commit is contained in:
@@ -20,6 +20,8 @@ The parts of the Spinbox are identical to the [Text area](/widgets/core/textarea
|
|||||||
|
|
||||||
`lv_spinbox_set_step(spinbox, 100)` sets which digits to change on increment/decrement. Only multiples of ten can be set, and not for example 3.
|
`lv_spinbox_set_step(spinbox, 100)` sets which digits to change on increment/decrement. Only multiples of ten can be set, and not for example 3.
|
||||||
|
|
||||||
|
`lv_spinbox_set_pos(spinbox, 1)` sets the cursor to a specific digit to change on increment/decrement. For example position '0' sets the cursor to the least significant digit.
|
||||||
|
|
||||||
### Format
|
### Format
|
||||||
|
|
||||||
`lv_spinbox_set_digit_format(spinbox, digit_count, separator_position)` sets the number format. `digit_count` is the number of digits excluding the decimal separator and the sign.
|
`lv_spinbox_set_digit_format(spinbox, digit_count, separator_position)` sets the number format. `digit_count` is the number of digits excluding the decimal separator and the sign.
|
||||||
|
|||||||
@@ -145,6 +145,23 @@ void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max)
|
|||||||
lv_spinbox_updatevalue(obj);
|
lv_spinbox_updatevalue(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cursor position to a specific digit for edition
|
||||||
|
* @param spinbox pointer to spinbox
|
||||||
|
* @param pos selected position in spinbox
|
||||||
|
*/
|
||||||
|
void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos)
|
||||||
|
{
|
||||||
|
|
||||||
|
lv_spinbox_t * spinbox = (lv_spinbox_t *)obj;
|
||||||
|
int32_t step_limit;
|
||||||
|
step_limit = LV_MAX(spinbox->range_max, (spinbox->range_min < 0 ? (-spinbox->range_min) : spinbox->range_min));
|
||||||
|
int32_t new_step = spinbox->step * lv_pow(10, pos);
|
||||||
|
if(pos <= 0) spinbox->step = 1;
|
||||||
|
else if(new_step <= step_limit) spinbox->step = new_step;
|
||||||
|
|
||||||
|
lv_spinbox_updatevalue(obj);
|
||||||
|
}
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ void lv_spinbox_set_step(lv_obj_t * obj, uint32_t step);
|
|||||||
*/
|
*/
|
||||||
void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max);
|
void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set cursor position to a specific digit for edition
|
||||||
|
* @param spinbox pointer to spinbox
|
||||||
|
* @param pos selected position in spinbox
|
||||||
|
*/
|
||||||
|
void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos);
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|||||||
Reference in New Issue
Block a user