Non-unicode IME support#3653
Non-unicode IME support#3653Othereum wants to merge 6 commits intoocornut:dockingfrom Othereum:non-unicode-ime
Conversation
|
Thank you @Othereum for this PR. I have a question: what is the reason for testing |
|
Well, maybe As you can see here, if the project uses unicode character set, wParam has a unicode encoded value. Therefore, you just need to add the input immediately without any further action. |
Then I suggest you then remove that check and move the other function was it was previously to minimize the patch? About unicode checking, I have also been used to test the UNICODE define but I wonder if we should simply just called |
|
Oh, you're right. Then why don't we merge it into master branch instead of docking branch? Should I make a new PR? |
|
Yes it we only modify the msg handler i think it could be done as a new PR over master.
|
|
I retested it when I got home and it didn't work properly when I enabled UTF-8 support in the system locale settings. So I fixed it using the |
|
I'm still waiting for your review, @ocornut :D |
|
Hello, |
fyi: |
Is that something that realistically happen? |
|
@Othereum I wanted to look at this today but I am confused. I verified that my project compiles with: Aka neither are defined. |
I am in the middle of moving, so don't have access to my notes, but if I recall correctly this is something that can happen when a window is subclassed, or flags of the window are altered. |
|
By the way we are discussing and resurrecting this over #9099 and hopefully will submit a solution soon. As posted in the other issue, it is correct that this PR cannot handle input of multiple consecutive characters. If I e.g. input 日本語 into the IME and then press ENTER only the first character ends up being submitted. The fix would be: case WM_IME_COMPOSITION:
{
//IMGUI_DEBUG_LOG("WM_IME_COMPOSITION wParam %08X, lParam %08X\n", wParam, lParam);
if (lParam & GCS_RESULTSTR)
{
if (HIMC himc = ::ImmGetContext(hwnd))
{
LONG buffer_size = ::ImmGetCompositionStringW(himc, GCS_RESULTSTR, NULL, 0);
ImVector<WCHAR> buffer;
buffer.resize((int)buffer_size / sizeof(WCHAR));
::ImmGetCompositionStringW(himc, GCS_RESULTSTR, buffer.Data, buffer_size);
::ImmReleaseContext(hwnd, himc);
for (WCHAR c : buffer)
io.AddInputCharacterUTF16(c);
}
}
return 0;
}
case WM_IME_CHAR:
return 1; // IME is processed above, so return 1 so that the WM_CHAR message is not generated.But I am aiming at a solution closer to #9099 so we don't require the user to link with imm32.lib. |
…nt (should be no-op?). Amend 0a7054c (ocornut#5725, ocornut#1807, ocornut#471, ocornut#2815, ocornut#1060 + ocornut#9099, ocornut#3653, ocornut#5961)
…pport Unicode inputs on MBCS Windows. (ocornut#9099, ocornut#3653, ocornut#5961)
This PR adds IME support for non-unicode projects. Korean, Japanese, and Chinese are affected by this PR.