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

IME input problem. #4642

Closed
urjskhzk opened this issue Oct 12, 2021 · 7 comments
Closed

IME input problem. #4642

urjskhzk opened this issue Oct 12, 2021 · 7 comments

Comments

@urjskhzk
Copy link

Version/Branch of Dear ImGui:

Version: 1.84.2
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: win32 dx9
Compiler: vs2019
Operating System: Windows 10

My Issue/Question:

This is a case when WM_CHAR and WM_LBUTTONDOWN events occur at the same time.

io.MouseDown[0]: true
io.InputQueueCharacters: Size 1, Data 44032 '가'

  1. Good
static bool b = false;
static char buf[256] = { 0, };
ImGui::Begin("Hello, world!");
ImGui::InputText("InputText", buf, _countof(buf));
ImGui::Checkbox("Checkbox", &b);
ImGui::End();

1

  1. Bad
static bool b = false;
static char buf[256] = { 0, };
ImGui::Begin("Hello, world!");
ImGui::Checkbox("Checkbox", &b);
ImGui::InputText("InputText", buf, _countof(buf));
ImGui::End();

2

  1. A is Good / B is Bad
static char buf1[36] = { 0, };
static char buf2[36] = { 0, };
ImGui::Begin("Hello, world!");
ImGui::InputText("A", buf1, _countof(buf1));
ImGui::InputText("B", buf2, _countof(buf2));
ImGui::End();

3

Screenshots/Video

Standalone, minimal, complete and verifiable example:

@ocornut
Copy link
Owner

ocornut commented Oct 12, 2021

This is not an IME specific problem but an IME triggering both events simultaneously would exacerbate the problem.

If you use a custom input queue like https://gist.github.com/ocornut/8417344f3506790304742b07887adf9f you can problably work around this problem. We are now working (well, thedmd is) on an official version of this to be in master.

@ocornut
Copy link
Owner

ocornut commented Oct 12, 2021

I assume that the click on checkbox makes the IME flush the unsubmitted text and send both events? Can you confirm that the WM_CHAR event is always sent before WM_LBUTTONDOWN ?

@urjskhzk
Copy link
Author

urjskhzk commented Oct 13, 2021

This is a situation that occurs frequently in the Korean input process.
I don't know about Chinese and Japanese input.
4
'R' is 'ㄱ' and 'K' is 'ㅏ'.

@urjskhzk
Copy link
Author

1

@LunaTheFoxgirl
Copy link

LunaTheFoxgirl commented Dec 22, 2021

Can confirm that the problem also happens with Japanese IME and in some cases (due to the SDL2 backend Inochi Creator is using) can cause crashes due to cut-off UTF8 sequences.
Though I think it's a bit of a multi-fold problem in our case.

@ocornut
Copy link
Owner

ocornut commented Aug 8, 2022

Hello,

Was looking into this day.
AFAIK this should be fixed by 1.87 event queue with a conforming backend (#4921) since text input trickles when preceded by a mouse down on same frame.

However, I can't repro (with io.ConfigInputTrickleEventQueue = false;) before with my IME showing a suggestion window, the first click is inhibited by win32 popup logic and I don't get the mouse down. However pretty sure it would now handle it properly with 1.87, but let me know if it doesn't!

@ocornut ocornut closed this as completed Aug 8, 2022
@ocornut
Copy link
Owner

ocornut commented Aug 8, 2022

PS: In the very last commit in Tools>DebugLog I have added a [X] IO checkbox allowing to visualize input events and how they are trickled.

ocornut added a commit that referenced this issue Jan 15, 2024
…87, favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.

Amend 3a90dc3 (#2589, #2598, #3108, #3113, #3653, #4642)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants