Skip to content

Commit

Permalink
checkkeys: don't toggle text input with the left mouse button
Browse files Browse the repository at this point in the history
This often gets triggered when clicking back and forth between the language bar and the application
  • Loading branch information
slouken committed Jun 25, 2024
1 parent a1fddc9 commit 6dfa688
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/checkkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,17 @@ static void loop(void)
break;
}
case SDL_EVENT_MOUSE_BUTTON_DOWN:
{
SDL_Window *window = SDL_GetWindowFromID(event.button.windowID);
if (SDL_TextInputActive(window)) {
SDL_Log("Stopping text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_StopTextInput(window);
} else {
SDL_Log("Starting text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_StartTextInput(window);
if (event.button.button == SDL_BUTTON_RIGHT) {
SDL_Window *window = SDL_GetWindowFromID(event.button.windowID);
if (SDL_TextInputActive(window)) {
SDL_Log("Stopping text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_StopTextInput(window);
} else {
SDL_Log("Starting text input for window %" SDL_PRIu32 "\n", event.button.windowID);
SDL_StartTextInput(window);
}
}
break;
}
case SDL_EVENT_KEYMAP_CHANGED:
SDL_Log("Keymap changed!\n");
PrintKeymap();
Expand All @@ -379,7 +379,7 @@ static void loop(void)

/* Draw the text */
SDL_SetRenderDrawColor(state->renderers[i], 255, 255, 255, 255);
SDL_snprintf(caption, sizeof(caption), "Text input %s (click mouse button to toggle)\n", SDL_TextInputActive(state->windows[i]) ? "enabled" : "disabled");
SDL_snprintf(caption, sizeof(caption), "Text input %s (click right mouse button to toggle)\n", SDL_TextInputActive(state->windows[i]) ? "enabled" : "disabled");
SDLTest_DrawString(state->renderers[i], TEXT_WINDOW_OFFSET_X, TEXT_WINDOW_OFFSET_X, caption);
SDLTest_TextWindowDisplay(textwindows[i], state->renderers[i]);

Expand Down

0 comments on commit 6dfa688

Please sign in to comment.