Skip to content

NOT A BUG: HOWTO - SDL3 and Textbox #72

Description

@linkdd

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions