diff --git a/apps/action.h b/apps/action.h index 9519bd0fc7..a1d54b22d8 100644 --- a/apps/action.h +++ b/apps/action.h @@ -156,6 +156,8 @@ enum { /* main menu */ ACTION_REQUEST_MENUITEM, ACTION_EXIT_MENUITEM, + ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit + once the subitem returns */ ACTION_ENTER_MENUITEM, ACTION_MENU_WPS, diff --git a/apps/menu.c b/apps/menu.c index 986c6b7034..0081d4964d 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -614,7 +614,14 @@ int do_menu(const struct menu_item_ex *start_menu) if (menu_callback) { + int old_action = action; action = menu_callback(action, menu); + if (action == ACTION_EXIT_AFTER_THIS_MENUITEM) + { + action = old_action; + ret = MENU_SELECTED_EXIT; /* will exit after returning + from selection */ + } } if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD)) diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 555c3493a0..b86ad0d230 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -1211,8 +1211,16 @@ MENUITEM_FUNCTION(radio_edit_preset_item, ID2P(LANG_FM_EDIT_PRESET), radio_edit_preset, NULL, NOICON); MENUITEM_FUNCTION(radio_delete_preset_item, ID2P(LANG_FM_DELETE_PRESET), radio_delete_preset, NULL, NOICON); +int radio_preset_callback(int action, const struct menu_item_ex *this_item) +{ + (void)this_item; + if (action == ACTION_STD_OK) + return ACTION_EXIT_AFTER_THIS_MENUITEM; + return action; +} MAKE_MENU(handle_radio_preset_menu, ID2P(LANG_FM_BUTTONBAR_PRESETS), - NULL, NOICON, &radio_edit_preset_item, &radio_delete_preset_item); + radio_preset_callback, NOICON, &radio_edit_preset_item, + &radio_delete_preset_item); /* present a list of preset stations */ char * presets_get_name(int selected_item, void * data, char *buffer) {