fix(roller): do not move when there is only one option (#6717)

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
Liam
2024-08-23 16:05:39 -04:00
committed by GitHub
parent e186b4c8b6
commit 7560fcb193

View File

@@ -349,10 +349,14 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
refr_position(obj, LV_ANIM_OFF);
}
else if(code == LV_EVENT_PRESSED) {
if(roller->option_cnt <= 1) return;
roller->moved = 0;
lv_anim_delete(get_label(obj), set_y_anim);
}
else if(code == LV_EVENT_PRESSING) {
if(roller->option_cnt <= 1) return;
lv_indev_t * indev = lv_indev_active();
lv_point_t p;
lv_indev_get_vect(indev, &p);
@@ -364,6 +368,8 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
}
}
else if(code == LV_EVENT_RELEASED || code == LV_EVENT_PRESS_LOST) {
if(roller->option_cnt <= 1) return;
release_handler(obj);
}
else if(code == LV_EVENT_FOCUSED) {
@@ -399,6 +405,8 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
}
}
else if(code == LV_EVENT_KEY) {
if(roller->option_cnt <= 1) return;
uint32_t c = lv_event_get_key(e);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(roller->sel_opt_id + 1 < roller->option_cnt) {
@@ -416,6 +424,8 @@ static void lv_roller_event(const lv_obj_class_t * class_p, lv_event_t * e)
}
}
else if(code == LV_EVENT_ROTARY) {
if(roller->option_cnt <= 1) return;
int32_t r = lv_event_get_rotary_diff(e);
int32_t new_id = roller->sel_opt_id + r;
new_id = LV_CLAMP(0, new_id, (int32_t)roller->option_cnt - 1);