diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-29 16:55:43 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-29 16:55:43 +0800 |
| commit | c9a461c52b37156f14944caa085bb794c184e5e3 (patch) | |
| tree | 139a30173393ccc6e1d1bb0fa64b12bd66192db5 /demos/dev/sdl-ime.c | |
| parent | 0b953f7f33b81491d5f3dd5df36f46d4c00891e4 (diff) | |
| download | cru-c9a461c52b37156f14944caa085bb794c184e5e3.tar.gz cru-c9a461c52b37156f14944caa085bb794c184e5e3.tar.bz2 cru-c9a461c52b37156f14944caa085bb794c184e5e3.zip | |
Add sdl-ime demo.
Diffstat (limited to 'demos/dev/sdl-ime.c')
| -rw-r--r-- | demos/dev/sdl-ime.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/demos/dev/sdl-ime.c b/demos/dev/sdl-ime.c new file mode 100644 index 00000000..0eccfa00 --- /dev/null +++ b/demos/dev/sdl-ime.c @@ -0,0 +1,38 @@ +#include <SDL3/SDL_events.h> +#include <SDL3/SDL_init.h> +#include <SDL3/SDL_timer.h> +#include <SDL3/SDL_video.h> +#include <stdio.h> + +int main() { + SDL_Window* window; + SDL_Rect area = {0, 0, 1, 1}; + int cursor = 0; + + window = SDL_CreateWindow("", 400, 200, 0); + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS); + SDL_SetTextInputArea(window, &area, cursor); + SDL_StartTextInput(window); + + SDL_Event e; + while (SDL_WaitEvent(&e)) { + if (e.type == SDL_EVENT_TEXT_INPUT) { + printf("%s: %s\n", "SDL_EVENT_TEXT_INPUT", e.text.text); + fflush(stdout); + } else if (e.type == SDL_EVENT_TEXT_EDITING) { + printf("%s: %s, start %i, length %i\n", "SDL_EVENT_TEXT_EDITING", + e.edit.text, e.edit.start, e.edit.length); + fflush(stdout); + } else if (e.type == SDL_EVENT_TEXT_EDITING_CANDIDATES) { + printf("%s: num_candidates %i, selected %i\n", + "SDL_EVENT_TEXT_EDITING_CANDIDATES", + e.edit_candidates.num_candidates, + e.edit_candidates.selected_candidate); + fflush(stdout); + } else if (e.type == SDL_EVENT_QUIT) { + break; + } + } + + SDL_Quit(); +} |
