diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 54aa332a24..759807a8b8 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -152,6 +152,14 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) *sel = nav->selection_ptr; } return true; + case MENU_NAVIGATION_CTL_SET_SELECTION: + { + size_t *sel = (size_t*)data; + if (!nav || !sel) + return false; + nav->selection_ptr = *sel; + } + return true; } return false; @@ -167,11 +175,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) void menu_navigation_set(menu_navigation_t *nav, size_t idx, bool scroll) { - if (!nav) - return; - - nav->selection_ptr = idx; - + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); } diff --git a/menu/menu_navigation.h b/menu/menu_navigation.h index 7f352f5920..cbfc4bdbe6 100644 --- a/menu/menu_navigation.h +++ b/menu/menu_navigation.h @@ -53,6 +53,7 @@ enum menu_navigation_ctl_state MENU_NAVIGATION_CTL_SET_LAST, MENU_NAVIGATION_CTL_DESCEND_ALPHABET, MENU_NAVIGATION_CTL_ASCEND_ALPHABET, + MENU_NAVIGATION_CTL_SET_SELECTION, MENU_NAVIGATION_CTL_GET_SELECTION };