#72·microui

NOT A BUG: HOWTO - SDL3 and Textbox

Author: linkddCreated May 23, 2025Updated May 23, 2025

First, thanks for the great work.

The demo is based on SDL2, but now SDL3 is generally available.

One key change between SDL2 and SDL3 has an impact on Textbox:

https://wiki.libsdl.org/SDL2/SDL_StartTextInput

On desktop platforms, SDL_StartTextInput() is implicitly called on SDL video subsystem initialization which will cause SDL_TextInputEvent and SDL_TextEditingEvent to begin emitting.

https://wiki.libsdl.org/SDL3/SDL_StartTextInput

Text input events are not received by default.

After calling mu_end(ctx), we need to check the ctx->focus variable (which, if true, means that some element wants to handle keyboard events) and enable/disable SDL's text input events:

c
mu_end(ctx);

if (ctx->focus != 0) {
    SDL_StartTextInput(window);
}
else {
    SDL_StopTextInput(window);
}

I'll leave that here in case someone else have the same problem.