Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backends: SDL3: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() #7452

Closed
wants to merge 1 commit into from

Conversation

Green-Sky
Copy link
Contributor

@Green-Sky Green-Sky commented Mar 28, 2024

SDL3 no longer enables text input by default. (libsdl-org/SDL#9309)
And should also play nicer with IME / virtual keyboards.

Without this "revert", no text inputs can be done on recent SDL3.

Amend: a7703fe

This patch is required for any of the SDL3 preview releases.

@EkajArmstro
Copy link

thanks for this, it appears to be working for me!

Green-Sky added a commit to Green-Sky/tomato that referenced this pull request Mar 30, 2024
@Fewnity
Copy link

Fewnity commented Apr 9, 2024

Oh thanks, now I understand why inputs are not working since I updated SDL and ImGui 😅

@ocornut
Copy link
Owner

ocornut commented Apr 15, 2024

IME doesn't seem to work with this. I'm really puzzled by SDL3 API to accept character inputs, as it is likely we may want them in situation where we don't want an OSD necessarily showing on all platforms.

@ocornut
Copy link
Owner

ocornut commented Apr 15, 2024

I have pushed your fix, however, note that IME inputs are currently essentially broken because somehow the keys (e.g. arrows, enter) gets sent to both the IME and the app, and app reacting to it usually means unfocusing the text widget.

I'm not sure how to fix that, I would appreciate if someone with SDL3 interest could investigate it.

I'm puzzled by SDL3 messing with system IME, when things would just work by default if it doesn't mess with it.

I'm also puzzled by the SDL_StartTextInput() design. Currently in other backends it is always possible for apps/widgets to access characters. I think there are situation where OSD keyboard may be opt-in rather than always on. e.g. if you want to implement a Windows Explorer-style "typing select" feature you need to read characters without an always-visible prompt.

@ocornut ocornut closed this Apr 15, 2024
@Green-Sky
Copy link
Contributor Author

I have pushed your fix, however, note that IME inputs are currently essentially broken because somehow the keys (e.g. arrows, enter) gets sent to both the IME and the app, and app reacting to it usually means unfocusing the text widget.

Ah that's somewhat unfortunate. I am not too familiar with how IMEs work in general.
Maybe we could discard certain inputs if SDL_TextInputActive() returns true?
other interesting functions: SDL_ClearComposition(), SDL_ScreenKeyboardShown()

I'm also puzzled by the SDL_StartTextInput() design. Currently in other backends it is always possible for apps/widgets to access characters. I think there are situation where OSD keyboard may be opt-in rather than always on. e.g. if you want to implement a Windows Explorer-style "typing select" feature you need to read characters without an always-visible prompt.

There is the hint SDL_HINT_IME_SHOW_UI, which can be set to enable/disable showing the IME, but I personally don't run imgui yet on systems where this is available.

@ocornut
Copy link
Owner

ocornut commented Apr 15, 2024

Maybe we could discard certain inputs if SDL_TextInputActive() returns true?

That would be incorrect and misleading. SDL_TextInputActive() is just a getter for what we write to and has nothing to do with the visibility of IME preview window. Which is also unrelated to visibility of an on-screen keyboard.

I think SDL3 is broken and someone needs to raise this to them.

There is the hint SDL_HINT_IME_SHOW_UI, which can be set to enable/disable showing the IME, but I personally don't run imgui yet on systems where this is available.

Things currently only work with this hint set to 1, as mentioned in backends and examples.
That's only the case in the first case as this hint controls hows SDL messes with IME. If it actually did nothing it would just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants