- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing UWP version of Xamarin Diagram.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Input locale not set in stand alone mode
Read 393 times

damiano   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Input locale not set in stand alone mode
Jun 6th, 2017 at 4:03pm
 
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
 
 
 
IP Logged    
 
     

Slavcho   Online
YaBB Moderator
*****
Posts: 1245
Gender: male
tech.support


   
     
 
Re: Input locale not set in stand alone mode
Reply #1 - Jun 6th, 2017 at 6:49pm
 
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
 
 
 
IP Logged    
 
     

damiano   Offline
YaBB Newbies
*
Posts: 2
I Love MindFusion!


   
     
 
Re: Input locale not set in stand alone mode
Reply #2 - Jun 7th, 2017 at 8:13am
 
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);
 
 
 
IP Logged    
 
     

Bleary Eye   Offline
YaBB Newbies
*
Posts: 12
I Love MindFusion!


   
     
 
Re: Input locale not set in stand alone mode
Reply #3 - Aug 17th, 2017 at 2:29pm
 
Slavcho wrote on Jun 6th, 2017 at 6: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?
 
 
 
IP Logged    
 
     

Slavcho   Online
YaBB Moderator
*****
Posts: 1245
Gender: male
tech.support


   
     
 
Re: Input locale not set in stand alone mode
Reply #4 - Aug 17th, 2017 at 2:53pm
 
It might be called Key.LANG in older versions of the control.
 
 
 
IP Logged    
 
     

Bleary Eye   Offline
YaBB Newbies
*
Posts: 12
I Love MindFusion!


   
     
 
Re: Input locale not set in stand alone mode
Reply #5 - Aug 21st, 2017 at 10:14pm
 
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?
 
 
 
IP Logged    
 
     

Bleary Eye   Offline
YaBB Newbies
*
Posts: 12
I Love MindFusion!


   
     
 
Re: Input locale not set in stand alone mode
Reply #6 - Aug 21st, 2017 at 10:40pm
 
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?
 
 
 
IP Logged    
 
     

Bleary Eye   Offline
YaBB Newbies
*
Posts: 12
I Love MindFusion!


   
     
 
Re: Input locale not set in stand alone mode
Reply #7 - Aug 21st, 2017 at 11:11pm
 
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.
 
 
 
IP Logged    
 
     

Slavcho   Online
YaBB Moderator
*****
Posts: 1245
Gender: male
tech.support


   
     
 
Re: Input locale not set in stand alone mode
Reply #8 - Aug 22nd, 2017 at 9:12pm
 
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
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print