Hi, Master
Version : LVGL v9.1
Problem :
I want to disable leading zeros in lv_spinbox
. For example, when the spinbox display range is 0.0~999.9
, the integer part has a dynamic number of digits. Currently, using lv_spinbox_set_digit_format(spinbox, 4, 3);
displays unnecessary leading zeros (e.g., 005.6
). I want it to show only the truly significant digits in the integer part (e.g., 5.6
).
Thanks
You can add something like this:
lv_spinbox_add_event_cb( spinbox, spinbox_value_changed_cb, LV_EVENT_VALUE_CHANGED, NULL );
void spinbox_value_changed_cb( lv_event_t* e )
{
lv_obj_t* spinbox = lv_event_get_target_obj( e );
int32_t value = lv_spinbox_get_value( spinbox );
if ( value >= 0 && value <= 9 )
{
lv_spinbox_set_digit_format(spinbox, 2, 1);
return;
}
else if ( value >= 10 && value <= 99 )
{
lv_spinbox_set_digit_format(spinbox, 3, 2);
return;
}
else if ( value >= 100 && value <= 999 )
{
lv_spinbox_set_digit_format(spinbox, 4, 3);
return;
}
}
OK, Thank you very much.