Skip to content

Commit d919938

Browse files
committed
fix scrolling bug
1 parent d2a2095 commit d919938

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/gsmenu/helper.c

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ lv_group_t *loader_group;
2929
pthread_t loader_thread;
3030
lv_obj_t *loader_msgbox = NULL;
3131

32+
void on_focus(lv_event_t* e)
33+
{
34+
lv_obj_t* obj = lv_event_get_current_target(e);
35+
lv_obj_scroll_to_view_recursive(lv_obj_get_parent(obj), LV_ANIM_ON);
36+
}
37+
3238
void loader_cancel_button_cb(lv_event_t * e) {
3339
printf("Cancelling loader thread\n");
3440

@@ -291,6 +297,7 @@ lv_obj_t * create_slider(lv_obj_t * parent, const char * icon, const char * txt,
291297
lv_obj_add_style(slider, &style_openipc, LV_STATE_FOCUS_KEY);
292298

293299
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_ALL, slider_label);
300+
lv_obj_add_event_cb(slider, on_focus, LV_EVENT_FOCUSED, NULL);
294301

295302
thread_data_t* data = malloc(sizeof(thread_data_t));
296303
if (data) {
@@ -326,6 +333,8 @@ lv_obj_t * create_button(lv_obj_t * parent, const char * txt)
326333

327334
lv_obj_add_style(btn, &style_openipc_outline, LV_PART_MAIN | LV_STATE_FOCUS_KEY);
328335
lv_obj_add_event_cb(btn, back_event_handler, LV_EVENT_KEY,NULL);
336+
lv_obj_add_event_cb(btn, on_focus, LV_EVENT_FOCUSED, NULL);
337+
329338

330339
return obj;
331340
}
@@ -416,6 +425,8 @@ lv_obj_t * create_switch(lv_obj_t * parent, const char * icon, const char * txt,
416425
}
417426

418427
lv_obj_add_event_cb(sw, back_event_handler, LV_EVENT_KEY,NULL);
428+
lv_obj_add_event_cb(sw, on_focus, LV_EVENT_FOCUSED, NULL);
429+
419430

420431
return obj;
421432
}
@@ -478,6 +489,7 @@ lv_obj_t * create_dropdown(lv_obj_t * parent, const char * icon, const char * la
478489

479490
lv_obj_add_event_cb(dd, generic_dropdown_event_cb, LV_EVENT_VALUE_CHANGED,data);
480491
lv_obj_add_event_cb(dd, back_event_handler, LV_EVENT_KEY,NULL);
492+
lv_obj_add_event_cb(dd, on_focus, LV_EVENT_FOCUSED, NULL);
481493

482494
get_dropdown_value(obj);
483495

0 commit comments

Comments
 (0)