diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index 1252c2ae9..8547c06ad 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -258,7 +258,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) } if(tic_api_btnp(menu->tic, A, -1, -1) - || tic_api_keyp(tic, tic_key_return, Hold, Period)) + || tic_api_keyp(tic, tic_key_return, Hold, Period)) { if(option) { @@ -286,6 +286,15 @@ static void drawMenu(Menu* menu, s32 x, s32 y) tic_rect rect = {x + (TIC80_WIDTH - width) / 2 + menu->anim.offset, y + TextMargin + ItemHeight * (i - menu->pos) - menu->anim.pos, it->width, TIC_FONT_HEIGHT}; + if (it->hotkey != tic_key_unknown && tic_api_keyp(tic, it->hotkey, Hold, Period)) + { + // hotkeys not supported on options for simplicity + if(it->option == NULL && it->handler) + onMenuItem(menu, it); + + menu->pos = it - menu->items; // set pos so that close will call this handler + } + bool down = false; if(animIdle(menu) && checkMousePos(menu->studio, &rect) && it->handler) { diff --git a/src/studio/screens/menu.h b/src/studio/screens/menu.h index 7eb9edcc1..f3815b711 100644 --- a/src/studio/screens/menu.h +++ b/src/studio/screens/menu.h @@ -23,6 +23,7 @@ #pragma once #include "tic80_types.h" +#include "tic.h" typedef struct Menu Menu; struct tic_mem; @@ -55,6 +56,7 @@ typedef struct const char* help; bool back; s32 width; + tic_keycode hotkey; } MenuItem; void studio_menu_init(Menu* menu, const MenuItem* items, s32 rows, s32 pos, s32 backPos, MenuItemHandler handler, void* data); diff --git a/src/studio/studio.c b/src/studio/studio.c index 73dc0b162..7570d0f95 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -1372,13 +1372,16 @@ void confirmDialog(Studio* studio, const char** text, s32 rows, ConfirmCallback studio->menuMode = studio->mode; studio->mode = TIC_MENU_MODE; - static const MenuItem Answers[] = + static MenuItem Answers[] = { {"", NULL}, - {"NO", confirmNo}, - {"YES", confirmYes}, + {"(N)O", confirmNo}, + {"(Y)ES", confirmYes}, }; + Answers[1].hotkey = tic_key_n; + Answers[2].hotkey = tic_key_y; + s32 count = rows + COUNT_OF(Answers); MenuItem* items = malloc(sizeof items[0] * count); SCOPE(free(items))