Merge pull request #1312 from patrykkrz/modification

Spinbox object - Cursor need shift to left after merge pull request #1220
This commit is contained in:
Gabor Kiss-Vamosi
2019-12-14 11:08:54 +01:00
committed by GitHub

View File

@@ -405,11 +405,15 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8]; char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
char * buf_p = buf; char * buf_p = buf;
uint8_t cur_shift_left = 0;
if (ext->range_min < 0) { // hide sign if there are only positive values if (ext->range_min < 0) { // hide sign if there are only positive values
/*Add the sign*/ /*Add the sign*/
(*buf_p) = ext->value >= 0 ? '+' : '-'; (*buf_p) = ext->value >= 0 ? '+' : '-';
buf_p++; buf_p++;
} else {
/*Cursor need shift to left*/
cur_shift_left++;
} }
int32_t i; int32_t i;
@@ -467,7 +471,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
if(cur_pos > intDigits) cur_pos++; /*Skip teh decimal point*/ if(cur_pos > intDigits) cur_pos++; /*Skip teh decimal point*/
cur_pos += ext->digit_padding_left; cur_pos += (ext->digit_padding_left - cur_shift_left);
lv_ta_set_cursor_pos(spinbox, cur_pos); lv_ta_set_cursor_pos(spinbox, cur_pos);
} }