mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-11 17:12:31 +00:00
Toggle menu visibility with the space bar
This commit is contained in:
@@ -143,8 +143,6 @@ static void loop()
|
|||||||
|
|
||||||
/* Check for events */
|
/* Check for events */
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
SDLTest_CommonEvent(state, &event, &done);
|
|
||||||
|
|
||||||
if (event.type == SDL_EVENT_MOUSE_MOTION) {
|
if (event.type == SDL_EVENT_MOUSE_MOTION) {
|
||||||
/* Hide the tooltip and restart the timer if the mouse is moved */
|
/* Hide the tooltip and restart the timer if the mouse is moved */
|
||||||
if (tooltip.win) {
|
if (tooltip.win) {
|
||||||
@@ -170,8 +168,22 @@ static void loop()
|
|||||||
++num_menus;
|
++num_menus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||||
|
if (event.key.keysym.sym == SDLK_SPACE) {
|
||||||
|
for (i = 0; i < num_menus; ++i) {
|
||||||
|
if (SDL_GetWindowFlags(menus[i].win) & SDL_WINDOW_HIDDEN) {
|
||||||
|
SDL_ShowWindow(menus[i].win);
|
||||||
|
} else {
|
||||||
|
SDL_HideWindow(menus[i].win);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Don't process this event in SDLTest_CommonEvent()
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDLTest_CommonEvent(state, &event, &done);
|
||||||
|
}
|
||||||
|
|
||||||
/* Show the tooltip if the delay period has elapsed */
|
/* Show the tooltip if the delay period has elapsed */
|
||||||
if (SDL_GetTicks() > tooltip_timer) {
|
if (SDL_GetTicks() > tooltip_timer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user