From a99eb6bb6ae12f3fcb86f5268a0c000fb165e159 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 4 May 2022 21:12:21 +0200 Subject: [PATCH] fix(spinbox): rename lv_spinbox_set_pos to lv_spinbox_set_cursor_pos fixes #3301 --- docs/widgets/extra/spinbox.md | 2 +- src/extra/widgets/spinbox/lv_spinbox.c | 2 +- src/extra/widgets/spinbox/lv_spinbox.h | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/widgets/extra/spinbox.md b/docs/widgets/extra/spinbox.md index 12d485cfe..03fab93df 100644 --- a/docs/widgets/extra/spinbox.md +++ b/docs/widgets/extra/spinbox.md @@ -20,7 +20,7 @@ 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_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. +`lv_spinbox_set_cursor_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. If an encoder is used as input device, the selected digit is shifted to the right by default whenever the encoder button is clicked. To change this behaviour to shifting to the left, the `lv_spinbox_set_digit_step_direction(spinbox, LV_DIR_LEFT)` can be used diff --git a/src/extra/widgets/spinbox/lv_spinbox.c b/src/extra/widgets/spinbox/lv_spinbox.c index 83f90865e..34691053e 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.c +++ b/src/extra/widgets/spinbox/lv_spinbox.c @@ -157,7 +157,7 @@ void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max) * @param spinbox pointer to spinbox * @param pos selected position in spinbox */ -void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos) +void lv_spinbox_set_cursor_pos(lv_obj_t * obj, uint8_t pos) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_spinbox_t * spinbox = (lv_spinbox_t *)obj; diff --git a/src/extra/widgets/spinbox/lv_spinbox.h b/src/extra/widgets/spinbox/lv_spinbox.h index 14c73ba36..1a4bc322f 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.h +++ b/src/extra/widgets/spinbox/lv_spinbox.h @@ -105,7 +105,7 @@ void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max); * @param obj pointer to spinbox * @param pos selected position in spinbox */ -void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos); +void lv_spinbox_set_cursor_pos(lv_obj_t * obj, uint8_t pos); /** * Set direction of digit step when clicking an encoder button while in editing mode @@ -170,6 +170,10 @@ void lv_spinbox_decrement(lv_obj_t * obj); * MACROS **********************/ +/* It was ambiguous in MicroPython. See https://github.com/lvgl/lvgl/issues/3301 + * TODO remove in v9*/ +#define lv_spinbox_set_pos lv_spinbox_set_cursor_pos + #endif /*LV_USE_SPINBOX*/ #ifdef __cplusplus