redo the previous commit so its actually useful.
if the callback returns ACTION_STD_CANCEL when the user presses ACTION_STD_OK the simple list will exit and set the selection. Otherwise, when ACTION_STD_CANCEL happens the selection will be set to -1 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18641 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
67df5f2434
commit
2438d7881a
2 changed files with 12 additions and 2 deletions
|
@ -893,12 +893,22 @@ bool simplelist_show_list(struct simplelist_info *info)
|
|||
|
||||
if (info->action_callback)
|
||||
{
|
||||
bool stdok = action==ACTION_STD_OK;
|
||||
action = info->action_callback(action, &lists);
|
||||
if (stdok && action == ACTION_STD_CANCEL) /* callback asked us to exit */
|
||||
{
|
||||
info->selection = gui_synclist_get_sel_pos(&lists);
|
||||
break;
|
||||
}
|
||||
|
||||
if (info->get_name == NULL)
|
||||
gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size);
|
||||
}
|
||||
if (action == ACTION_STD_CANCEL)
|
||||
{
|
||||
info->selection = -1;
|
||||
break;
|
||||
}
|
||||
else if ((action == ACTION_REDRAW) ||
|
||||
(old_line_count != simplelist_line_count))
|
||||
{
|
||||
|
@ -910,7 +920,6 @@ bool simplelist_show_list(struct simplelist_info *info)
|
|||
else if(default_event_handler(action) == SYS_USB_CONNECTED)
|
||||
return true;
|
||||
}
|
||||
info->selection = gui_synclist_get_sel_pos(&lists);
|
||||
talk_shutup();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,8 @@ struct simplelist_info {
|
|||
int timeout;
|
||||
int selection; /* the item to select when the list is first displayed */
|
||||
/* when the list is exited, this will be set to the
|
||||
index of the last item selected */
|
||||
index of the last item selected, or -1 if the list
|
||||
was exited with ACTION_STD_CANCEL */
|
||||
int (*action_callback)(int action, struct gui_synclist *lists); /* can be NULL */
|
||||
/* action_callback notes:
|
||||
action == the action pressed by the user
|
||||
|
|
Loading…
Reference in a new issue