Changing input language
I am trying to implement an input language change for an application using WebView2 hosted in WPF application, the problem is that most of the common ways to change the language don't work.
WPF InputLanguageManager.Current.CurrentInputLanguage no effect
Win32 ActivateKeyboardLayout no effect
Changing the windows language manually does make WebView to use correct language, so the question is whether I am missing something or the only way is to programmatically switch windows input language ?
I have outlined the problem here
Hi @olegsavelos could you please provide some more information about this?
• Framework (WinUI, Win32, WinForms, UWP, WPF, etc)
• SDK and Runtime version.
• Operating System
WPF .NET 6.0.15 Windows 11 22h2 22621.1265
@olegsavelos Thanks for providing the info. We've added it to our bug backlog.
@olegsavelos Thanks for providing the info. We've added it to our bug backlog.
Thanks! So you can confirm its a bug ?
@olegsavelos , can you try CoreWebView2EnvironmentOptions.Language Property to see whether it helps with your scenario ?
I have tried specifying the language in OnWebViewInitializing event handler
_BLAZOR_WEB_VIEW.BlazorWebViewInitializing = new EventHandler<BlazorWebViewInitializingEventArgs>(OnWebViewInitializing);
private void OnWebViewInitializing(object sender, BlazorWebViewInitializingEventArgs e)
{
e.EnvironmentOptions = new CoreWebView2EnvironmentOptions()
{
Language = "gr",
};
}
Nothing changes, all inputs are in English.
@novac42 Is there any updates on this issue ?
@olegsavelos sorry it's in our backlog but due to resource limitation we haven't got chance to work on it. May you help us understand the urgency of this issue? Is it a critical blocker?
@olegsavelos sorry it's in our backlog but due to resource limitation we haven't got chance to work on it. May you help us understand the urgency of this issue? Is it a critical blocker?
Kinda, we have a feature in the application change input language and it will just not work. You can confirm that this is a bug and dont require demo project right ?
@novac42 is there any update on this issue or any workaround ? I cant be sure but it looks like the problem is related to input language change message I was able to set the language by sending broadcast window message like this
User32.SendNotifyMessage(new IntPtr(0xFFFF),(uint)WM.WM_INPUTLANGCHANGEREQUEST,(IntPtr)INPUTLANGUAGE.INPUTLANGCHANGE_SYSCHARSET,(IntPtr)culture.LCID);
This does change the language BUT the problem still remains where its not possible to detect current language change when its done by the windows shortcuts, the web view hosting window needs to loose focus in order to receive the change event and User32.GetKeyboardLayout will be reporting old value until its done.
Adding to my previous comment I can add the following. If any other window has focus (foreground) changing language with shortcuts alt+shift does cause the User32.GetKeyboardLayout to report correct language for that window. If WPF edge web view has focus the HTML components (Inputs) do have correct input language but User32.GetKeyboardLayout will still report previous language until the window looses focus. @novac42
I have tried to see what potential workarounds could be done and so far the only viable one would be to use WH_SHELL hook but writing an native hook library is an overkill, please provide any potential workarounds.
@novac42 should I expect this to be fixed or acknowledged at least?
Should we expect any updates on this ?
Hi! Sorry for the delay - there has been some personnel shifts. I will get someone to look into this for you
This bug is still unfixed. WM_INPUTLANGCHANGE is not propagated to the host WPF window so there is no way to detect language change.