-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Workaround to disable the incomplete UI-less mode IME in SDL(Windows) #1953
Conversation
vby
commented
Jul 18, 2018
- Set io.ImeSetInputScreenPosFn use SDL_SetTextInputRect
- SDL try to support UI-less mode IME on Windows, but the implementation is incomplete, that make the default IME window not shown. I made a workaround to disable it.
Hello @vby and thanks a lot for the PR! I was actually puzzled by this issue a few months ago, noticed how SDL was severely messing up with the IME (and when I looked at the SDL code I can't find a way that even the SDL IME can work under Win32). Why can't the code you added in ImGui_ImplSDL2_CreateWindow() be normally handled in It seems a little strange to be adding this extra entry point, hiding the raw SDL_CreateWindow away from the demo is problematic. If for some reason the code cannot be handled in
Thank you, |
SDL will initalize UI-less mode IME when the first window got focus, we need setup the hook before it.
It seems hard to implement ImGui_ImplSDL2_HookIme. English is not mother tongue, I can't give a good explain in the code comment, sorry about that. |
Hello @vby, I looked at this today. If I press Backspace it is forwarded to both IME and imgui, When you tested it, did it works OK? -Omar |
Ping @vby |
@ocornut I found out a way to implement the ImGui_ImplSDL2_HookIme, but need an extra function ImGui_ImplSDL2_Init, you can merge it with the SDL_init maybe. |
Nice finding the workaround! I confirmed the issue with keys here. I am using Windows 10 + Microsoft IME + SDL 2.0.8, Keyboard set in Japanese. |
@ocornut The issue is about the VK_PROCESSKEY, I added a new wndproc hook to fix it. |
This fix this issue but now the Space key (not Space char!) doesn't get to imgui when e.g. Japanese language is active. |
I don't think it is an issue, the Space is a char not a key down when IME is active. |
When IME popup is not active we need the Space key to use keyboard navigation (activate item, etc.). Right now even when IME popup is not active it we can't use Space anymore. |
It is not about whether the IME popup is shown, IME popup is not shown, but the IME is still enabled. The imgui Windows examples seems has the same issue, because the Microsoft Japanese IME processed Space to emit a space char(half-width or full-width) that prevent the TranslateMessage to emit a char and Windows will replace the wParam to VK_PROCESSKEY, while the Chinese IME do not. Consider maybe some IME will use Space as a composition char, and press Space will show composition window and do the action bound by imgui, that was a little strange. I add fix that emit normal key down(by SDL wndproc) only if not WantTextInput as a middle ground. |
This is a problem in imgui_impl_win32.cpp and maybe need to be fixed accross more back-end. |
Since other back-ends have the same issue, I will merge your SDL PR for now. |
I added a fix that disable IME if not io.WantTextInput, avoid problems introduce by IME, other back-ends can also fix by the same way. There is a small problem between the io.ImeSetInputScreenPosFn and io.WantTextInput, io.ImeSetInputScreenPosFn called by EndFrame but io.WantTextInput set by NewFrame, that will make io.ImeSetInputScreenPosFn called before application get the io.WantTextInput state, the IME may not enable, make the backend a little hard to write. It's better if we have io.TextInputPos(or io.TextInputRect due to the candidate window orientation) and io.WantSetTextInputPos like io.MousePos and io.WantSetMousePos. CJK players always suffering from the IME problems in video games, we usually switch to English language(keyboard layout) when playing and switch to native language when typing, there are many games even can't use IME. The default IME window is not well supported on some full-screen mode, it is fantastic if adding built-in IME windows(Reading, Composition, Candidate, Input Locale indicator, etc.), or a widget like DXUTguiIME.cpp. Do you have any plan or idea about this feature, much thanks for your attention to the IME compatibility. |
Thank you for the update! Can you clarify how the new Could the new
This is a good idea, I will look into this. The design for this already changed in the docking branch (for multi-viewport we need to specify the viewport). You are right it would be more flexible and consistent to do it this way. Can you explain how dear imgui may set the
I don't have a specific plan, mostly because this would be too much work for me. |
The candidate window may have two directions, due to the available space under the input position, so we need two point(the cursor line) to draw the candidate window more accurate, point also is fine. |
OK, so I think we can come up with ANOTHER design, maybe the right one this time :) We can have 1 function More-over, it makes sense for multi-viewport branch ( This should work. And on the side I will rework the TextInputPos API as well. |
Hello @vby this is useful and I would like to get this into dear imgui, any reason why you closed this? |
@vby ? |
The workaround is just make the example works, it is too intrusive to use within an existing SDL based project, and may have some corner cases not working as expected. So I closed the PR, finding a new way or wait for SDL to fix this issue. |
Here |