Does anyone know how I could easily detect if the Windows OS IME (Input Method Editor) is active in the Silverlight framwork. Let me explain the scenario which is causing me issues:
I have hit an issue where using a Chinese (Simplified, China) Microsoft Pinyin causes a CLR exception. The scenario is when a TextBox is handling its TextChanged event. For example:
In WPF it is possible to overcome this issue by not reversing the Text in the TextChanged event by using the InputMethod.Current.ImeState to check if an IME is active. Unfortunately this is not available in the Silverlight framework which is why I am posting this question.
Currently the only thing I have found is that I could set IsInputMethodEnabled property of the InputMethod class to the TextBox control in order disable all IME input but this of course will not only disable the incorrect input but also the correct one.
Anyone has any ideas how I could detect if a IME is used/active in the Silverlight platform? Thanks.
I was able to resolve the issue in both the WPF and Silverlight frameworks. The issue was caused by the fact that by handling the TextBox Text while a IME is inputting symbols that Text was making the IME itself change its input which it looks like is not handled gracefully by the Windows OS and was causing a CLR exception.
What I did was:
In the WPF framework as mentioned I used the static InputMethod.Current.ImeState value to determine if IME is active and if it was with On value I skipped reverting the TextBox Text property in its TextChanged event.
In the Silverlight framework I use a combination of the TextInputStart, TextInputUpdate events and a local private field to store if IME was detected. The TextInputUpdate event is only triggered if IME is active and used as input and the TextInputStart is always triggered. What I did was:
Hope this is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With