Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Input locale not set in stand alone mode (Read 5838 times)
damiano
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jun 6th, 2017
Input locale not set in stand alone mode
Jun 6th, 2017 at 3:03pm
Print Post  
Hello,

I am using your WPF VirtualKeyboard control. I need it to behave like Windows on screen keyboard, so I set IsStandAlone to true. This works fine.

I also would like to set InputLocale programmatically, but when I try to set this property nothing happens.

Could someone help me please ?

Thanks
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Input locale not set in stand alone mode
Reply #1 - Jun 6th, 2017 at 5:49pm
Print Post  
Hi,

Right, this setter only calls ActivateKeyboardLayout API function which changes input language of current (yours) process. So the keyboard tracks input language in foreground window and sets InputLocale automatically to match it, overriding your value. If you need to toggle between installed languages in target application, you could call keyboard.SendKey(Key.Lang) instead - this sends a WM_INPUTLANGCHANGEREQUEST to the foreground window and leads to ActivateKeyboardLayout being called in that application's process.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
damiano
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jun 6th, 2017
Re: Input locale not set in stand alone mode
Reply #2 - Jun 7th, 2017 at 7:13am
Print Post  
Hi,

thank you for the quick answer. Toggleing layout with keyboard.SendKey(Key.Lang) is not exactly what I tried to do. Finally I could select a locale by calling PostMessage(hWnd, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, MYLOCALE);
  
Back to top
 
IP Logged
 
Bleary Eye
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Aug 17th, 2017
Re: Input locale not set in stand alone mode
Reply #3 - Aug 17th, 2017 at 1:29pm
Print Post  
Slavcho wrote on Jun 6th, 2017 at 5:49pm:
If you need to toggle between installed languages in target application, you could call keyboard.SendKey(Key.Lang) instead - this sends a WM_INPUTLANGCHANGEREQUEST to the foreground window and leads to ActivateKeyboardLayout being called in that application's process. Slavcho

I need to switch keyboard language in the application only. The system language must always be English. I tried the SendKey mentioned but Key.Lang does not exist. What do I need to do?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Input locale not set in stand alone mode
Reply #4 - Aug 17th, 2017 at 1:53pm
Print Post  
It might be called Key.LANG in older versions of the control.
  
Back to top
 
IP Logged
 
Bleary Eye
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Aug 17th, 2017
Re: Input locale not set in stand alone mode
Reply #5 - Aug 21st, 2017 at 9:14pm
Print Post  
I have the keyboard in a separate window similar to the example that was installed. I have code like:

Quote:
VirtualKeyboard.Language = XmlLanguage.GetLanguage("es-mx");
VirtualKeyboard.SendKey(Key.Lang);


VirtualKeyboard.Language is set correctly and stays set, but the display remains English rather than Spanish. I tried the SendKey as you suggested above but no difference. I tried other languages, same result.

I also tried the suggestion in https://stackoverflow.com/a/14750885, putting the code in the window hosting the keyboard, but that didn't work either.

What should i try?
  
Back to top
 
IP Logged
 
Bleary Eye
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Aug 17th, 2017
Re: Input locale not set in stand alone mode
Reply #6 - Aug 21st, 2017 at 9:40pm
Print Post  
Another note. I can change languages by clicking the language button. But I don't just want to toggle. I'll have a list of about 15 languages and have to be able to specify precisely which one.

What's the code that's executed when the language key is pressed?
  
Back to top
 
IP Logged
 
Bleary Eye
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: Aug 17th, 2017
Re: Input locale not set in stand alone mode
Reply #7 - Aug 21st, 2017 at 10:11pm
Print Post  
After more checking online and trial, here's what works:

Quote:
InputLanguageManager.Current.CurrentInputLanguage = cultureInfo;


This does not change the overall system language (stays English); that's good. However, it also does not change what's displayed in the keyboard language key. That's a nuisance but not fatal.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Input locale not set in stand alone mode
Reply #8 - Aug 22nd, 2017 at 8:12pm
Print Post  
Quote:
VirtualKeyboard.Language = XmlLanguage.GetLanguage("es-mx");

This XmlLanguage property is defined in base FrameworkElement and is not used by the keyboard control. Instead you could set keyboard.InputLocale = new CultureInfo("es-mx");

This will have effect mostly when not in stand-alone mode, which sets InputLocale automatically depending on foreground window's current language.

The Lang key sends WM_INPUTLANGCHANGEREQUEST to foreground window. As Damiano noted above you can call
PostMessage(hWnd, WM_INPUTLANGCHANGEREQUEST, INPUTLANGCHANGE_FORWARD, MYLOCALE) to request a specific language.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint