ryancheung / ImeSharp

C# wrapper for Windows IME APIs
MIT License
71 stars 12 forks source link

Korean doesn't work with TSF #10

Open nikitabuyevich opened 3 years ago

nikitabuyevich commented 3 years ago

When TSF is installed/enabled, Korean stops working (The behavior is unexpected and the composition string stops being rendered)

ryancheung commented 3 years ago

I've just #11 , the composition string is empty (filled with some empty characters?). Can you confirm that there's no other issue with Korean IME? BTW, I've no idea of how Korean IME works.

nikitabuyevich commented 3 years ago

Hey,

So if you just disable TSF (Set TextServicesLoader's ServicesInstalled function to return false, so it fallbacks on IMM32) it behaves correctly/as expected. Essentially the composition is build up and gets automatically inserted on certain criteria.

I don't know Korean either but here's an example you can run to test if it's working properly (Which is how it's currently working with just IMM32)

Spamming a on your keyboard.

1) Type a on your keyboard, the composition should be filled with while the text input is empty. 2) Type a on your keyboard again, the composition remains the same character as last time but now the text input should contain . 3) If you keep pressing a on your keyboard you'll get the second scenario repeating.

Changing the composition

1) Type a on your keyboard, the composition string should be filled with while the text input is empty. 2) Type b on your keyboard, the composition string should change to while the text input is empty. 3) Type c on your keyboard, the composition string should change to while the text input is empty. 4) Type a on your keyboard, the composition string changes to while is inserted into the text input.

When I attempt the same scenario with TSF enabled, the composition string is always empty and everything is immediately inserted into the text input. I think what's supposed to happen is that OnEndComposition is called whenever the composition ends (like in scenario 4 when the user typed a and the composition finished building) and only then should the text input be inserted.

I have this project replicated in C++ but I'm getting different behavior where the composition string is being filled up properly but my text input remains empty.

Does that help? Let me know how I can help since I'm kind of stuck on where to take it from here.

ryancheung commented 3 years ago

There's no correct way to fix composion ends on every key press in TSF, I tried.

But, since we have IMM32 works, we could force to IMM32 for Korean IME. This could be a workaround at the moment. What do you think?

nikitabuyevich commented 3 years ago

Yeah it's a thought I had and something I tried without much success. I've created a new PR (#12) where we can play around with it to toggle it.

The issue is once I unregister and then attempt to register the TSF again, none of the sinks get hit again.

ryancheung commented 3 years ago

I tried with that approach yesterday. It has the issue you put. It seems not possible to be fixed. So I created https://github.com/ryancheung/ImeSharp/tree/option-to-force-disable-tsf

waltdestler commented 1 month ago

Hi, it looks like Korean isn't working regardless of whether TSF is enabled or not. The callbacks sent by ImeSharp do not provide the necessary info to properly update already-entered Korean characters.

As an example, here is the correct sequence of what should happen when pressing the DLEK keys on a keyboard:

D
ㅇ

DL
이

DLE
읻

DLEK
이다

Notice that when the K key is pressed, the previously-entered 읻 (DLE) character reverts to 이 (DL) and then the new character 다 (EK) is appended.

However, ImeSharp reports no change to the 읻 character once K is pressed. Here's the same sequence of keys and the corresponding characters as reported by ImeSharp:

D
ㅇ

DL
이

DLE
읻

DLEK
읻다

This happens regardless of whether tsfForceDisabled is true or not.