Mobile: Fix can't close tab list if you press Tab on keyboard (Thanks aleksb385)

This commit is contained in:
UnknownShadow200 2021-05-03 21:07:19 +10:00
parent 408eaeeee6
commit 1dda4de936

View File

@ -331,7 +331,7 @@ typedef int (*TabListEntryCompare)(int x, int y);
static struct TabListOverlay { static struct TabListOverlay {
Screen_Body Screen_Body
int x, y, width, height; int x, y, width, height;
cc_bool active, classic; cc_bool active, classic, staysOpen;
int namesCount, elementOffset; int namesCount, elementOffset;
struct TextWidget title; struct TextWidget title;
struct FontDesc font; struct FontDesc font;
@ -633,7 +633,7 @@ static int TabListOverlay_PointerDown(void* screen, int id, int x, int y) {
static void TabListOverlay_KeyUp(void* screen, int key) { static void TabListOverlay_KeyUp(void* screen, int key) {
struct TabListOverlay* s = (struct TabListOverlay*)screen; struct TabListOverlay* s = (struct TabListOverlay*)screen;
if (key != KeyBinds[KEYBIND_TABLIST] || Input_TouchMode) return; if (key != KeyBinds[KEYBIND_TABLIST] || s->staysOpen) return;
Gui_Remove((struct Screen*)s); Gui_Remove((struct Screen*)s);
} }
@ -727,7 +727,8 @@ static const struct ScreenVTABLE TabListOverlay_VTABLE = {
}; };
void TabListOverlay_Show(void) { void TabListOverlay_Show(void) {
struct TabListOverlay* s = &TabListOverlay_Instance; struct TabListOverlay* s = &TabListOverlay_Instance;
s->VTABLE = &TabListOverlay_VTABLE; s->VTABLE = &TabListOverlay_VTABLE;
s->staysOpen = false;
Gui_Add((struct Screen*)s, GUI_PRIORITY_TABLIST); Gui_Add((struct Screen*)s, GUI_PRIORITY_TABLIST);
} }
@ -1973,6 +1974,7 @@ static void TouchScreen_TabClick(void* s, void* w) {
Gui_Remove((struct Screen*)&TabListOverlay_Instance); Gui_Remove((struct Screen*)&TabListOverlay_Instance);
} else { } else {
TabListOverlay_Show(); TabListOverlay_Show();
TabListOverlay_Instance.staysOpen = true;
} }
} }