Custom menu items confirm option (#21338)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
InsanityAutomation
2021-03-13 08:37:49 -05:00
committed by GitHub
parent da84b59ee4
commit 911cd1a6d3
3 changed files with 28 additions and 7 deletions

View File

@ -46,7 +46,20 @@ void _lcd_user_gcode(PGM_P const cmd) {
void menu_user() {
START_MENU();
BACK_ITEM(MSG_MAIN);
#define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); });
#define GCODE_LAMBDA(N) []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); }
#define _USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), GCODE_LAMBDA(N));
#define _USER_ITEM_CONFIRM(N) \
SUBMENU_P(PSTR(USER_DESC_##N), []{ \
MenuItem_confirm::confirm_screen( \
GCODE_LAMBDA(N), \
ui.goto_previous_screen, \
PSTR(USER_DESC_##N "?") \
); \
})
#define USER_ITEM(N) do{ if (ENABLED(USER_CONFIRM_##N)) _USER_ITEM_CONFIRM(N); else _USER_ITEM(N); }while(0)
#if HAS_USER_ITEM(1)
USER_ITEM(1);
#endif

View File

@ -211,11 +211,13 @@ void menu_main() {
SUBMENU(MSG_CONFIGURATION, menu_configuration);
#if ENABLED(CUSTOM_USER_MENUS)
#ifdef CUSTOM_USER_MENU_TITLE
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
#else
SUBMENU(MSG_USER_MENU, menu_user);
#endif
if (TERN1(CUSTOM_MENU_ONLY_IDLE, !busy)) {
#ifdef CUSTOM_USER_MENU_TITLE
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
#else
SUBMENU(MSG_USER_MENU, menu_user);
#endif
}
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)