Skip to content

Commit 8e458ba

Browse files
add simple input detection
Immediate-Mode-UI#779 (comment)
1 parent 3c93b54 commit 8e458ba

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

demo/sdl3/nuklear_sdl3_renderer.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,21 @@ nk_sdl_handle_event(struct nk_context* ctx, SDL_Event *evt)
303303
NK_ASSERT(ctx);
304304
NK_ASSERT(evt);
305305

306+
static bool was_active = false;
307+
const bool active = (ctx->active && ctx->active->edit.active) ||
308+
(ctx->active && ctx->active->popup.win && ctx->active->popup.win->edit.active);
309+
SDL_Window *win = SDL_GetWindowFromEvent(evt);
310+
struct nk_sdl* sdl = (struct nk_sdl*)ctx->userdata.ptr;
311+
if (active != was_active && win == sdl->win)
312+
{
313+
if (!was_active && active)
314+
SDL_StartTextInput(win);
315+
else if (was_active && !active)
316+
SDL_StopTextInput(win);
317+
was_active = active;
318+
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "text input %s", active ? "started" : "stopped");
319+
}
320+
306321
switch(evt->type)
307322
{
308323
case SDL_EVENT_KEY_UP: /* KEYUP & KEYDOWN share same routine */

0 commit comments

Comments
 (0)