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

Marked Text / SDL_TEXTEDITING Event / IME Composition support #5878

Open
vkedwardli opened this issue Nov 10, 2022 · 5 comments · May be fixed by #6661
Open

Marked Text / SDL_TEXTEDITING Event / IME Composition support #5878

vkedwardli opened this issue Nov 10, 2022 · 5 comments · May be fixed by #6661
Labels

Comments

@vkedwardli
Copy link

It was briefly discussed in #3108

Need to figure out whether need to add markedText support and how.
It requires to display the markedText, but not sure with imgui, what's
the best way of doing that

As an example, the Lite XL app is handling the Composition perfectly
(it is backed by SDL2, composition string, selected range are feed from the SDL_TEXTEDITING event)
Nov-10-2022 15-12-44

//  [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME.

The above statement is partially correct, with the SDL_HINT_IME_SHOW_UI, imgui with SDL2 can show the Candidate List, but the Composition is feeding from SDL_TEXTEDITING event, and requires you to draw it.
image

With SDL_DISABLE_WINDOWS_IME, Windows will be responsible for drawing the Composition also, but unfortunately other OS e.g. macOS, does not draw it for you.

What would be the preferred approach to implement this? I could try to make a PR

@ocornut ocornut added the ime label Nov 10, 2022
@vkedwardli
Copy link
Author

Relevant project:
github/maildrop/DearImGui-with-IMM32

@ocornut
Copy link
Owner

ocornut commented Feb 7, 2023

IHMO SDL is putting too much burden on the app with SDL_TEXTEDITING / SDL_TEXTEDITING_EXT but it should be possible to handle. We'd need to draw a blinking caret and mainly design all the IO for it.

I guess it could be a io.AddImeTextEditingEvent(const char* str, int start, int length); or io.AddPlatformImeTextEditingEvent() but we'd need to investigate the data provided by other tech to design the best API. Perhaps safer to pass this in a structure so it may be extended.

Then dear imgui needs to somehow store this data and draw it with a caret.

@iacore
Copy link

iacore commented Jul 29, 2023

IBus makes this an option.

IBus Preferences:
image

https://github.com/ibus/ibus/blob/dfad02bb00ecf24a0f3b403c0aa96ad4890bdcb1/data/dconf/org.freedesktop.ibus.gschema.xml#L93-L97

In XTerm, the preedit text is displayed by IBus even if this option is turned on.

peek.xterm.mp4

So there must be some way to display this text.

@iacore
Copy link

iacore commented Jul 29, 2023

SDL_HINT_IME_SHOW_UI seems to be a Windows-only feature. Not sure what it does.

https://github.com/search?q=repo%3Alibsdl-org%2FSDL%20SDL_HINT_IME_SHOW_UI&type=code

Anyway I've fixed it.

@vkedwardli
Copy link
Author

@iacore I don't think your PR can fix this issue.

From SDL2 2.0.4 changelog:

Added IBus IME support
Added a hint SDL_HINT_IME_INTERNAL_EDITING to control whether IBus should handle text editing internally instead of sending SDL_TEXTEDITING events

SDL_HINT_IME_INTERNAL_EDITING is for IBus only (at that time, but I don't know what other platforms support this).

I've showed what SDL_HINT_IME_SHOW_UI can achieve in the screenshots when discussing about the Windows IME support in current IMGUI/SDL, this issue is not aiming to solve a specific platform (or else I could just make a PR for Windows), but to see what should be done to support all platforms, so I was asking the feasibility on implementing SDL_TEXTEDITING

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

Successfully merging a pull request may close this issue.

3 participants