Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change language (Read 406 times)
ruki
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Oct 5th, 2023
Change language
Oct 5th, 2023 at 7:19am
Print Post  
I am evaluating the virtual keyboard for my kiosk application. I need to be able to change the language of the keyboard irrespective of the language of the system. Is this possible?

I see the documentation says to call the overload ChangeLanguage function. I cannot find it. Can you show some sample code.

Also is it a requirement to have the Windows language add-ons downloaded for the language I want to support ? Ideally this is not the case.

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


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Change language
Reply #1 - Oct 5th, 2023 at 9:39am
Print Post  
Hi,

ChangeLanguage methods were added with the very last v5.0.3 release, make sure that's what you are using.

The RegularKey objects used in default keyboard layouts rely on the OS to convert virtual key codes to respective character for language. So you'd need to have the Windows keyboard language installed indeed (you can omit all optional components like Language Pack, just install the core keyboard layout).

If you don't want to rely on installed Windows language, you could use UnicodeKey to directly send character codes, but  would have to create custom layouts for any language you need to support in that case.

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


I Love MindFusion!

Posts: 11
Joined: Oct 5th, 2023
Re: Change language
Reply #2 - Oct 6th, 2023 at 4:01am
Print Post  
Thanks I have downloaded the latest and the ChangeLanguage is available.

I have the Japanese Windows keyboard language installed.

I have this in my code

Code
Select All
        public MainWindow()
        {
            InitializeComponent();

            Keyboard.ChangeLanguage("jp-JP");
        }
 



However the keyboard is still in English language. There is a language cycling button and if I press that I can get to Japanese. Any reason why the above didn't work?

Also I am assuming for me to remove the language switching button I have to create my custom layout, or is there an option?

Also further I have a TextBox in my sample app however the keyboard is not entering any text. However opening up Notepad.exe text is being entered. Is this a limitation of the trial version?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Change language
Reply #3 - Oct 6th, 2023 at 10:51am
Print Post  
Quote:
Also further I have a TextBox in my sample app however the keyboard is not entering any text. However opening up Notepad.exe text is being entered. Is this a limitation of the trial version?


If the TextBox is in the same window as the keyboard, you might have to set VirtualKeyboard.IsStandAlone property to false.

Generally we support three different configurations - the default standalone mode sends to external applications, and otherwise the keyboard could either show in child window of the application to send keystrokes to its other windows, or it could be in the same window as input controls. These are shown by sample projects installed with the control, please copy settings from the one closest to your scenario.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Change language
Reply #4 - Oct 6th, 2023 at 12:26pm
Print Post  
Quote:
Also I am assuming for me to remove the language switching button I have to create my custom layout, or is there an option?


You could remove the key from default layouts like this:

Code
Select All
vk.Mode = KeyboardMode.Extended;
var defaultLayout = vk.Layout;
defaultLayout.Keys.Remove(MindFusion.UI.Wpf.Key.Lang);
vk.TemplateLayout = defaultLayout; 


  
Back to top
 
IP Logged
 
ruki
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: Oct 5th, 2023
Re: Change language
Reply #5 - Oct 9th, 2023 at 4:05am
Print Post  
Thanks I have got most of it working. However why is the keyboard not switched to Japanese keyboard even with this code?

Code
Select All
            vkb.ChangeLanguage("ja-JP");
 



I already have the Japanese language pack. I can see the Japanese keyboard if I press on the language key in the virtual keyboard.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Change language
Reply #6 - Oct 9th, 2023 at 9:21am
Print Post  
Hi,

ja-JP works on my end, while the jp-JP you mentioned in first post does not. That should be equivalent to following assignment, so you could try it too:

Code
Select All
InputLanguageManager.Current.CurrentInputLanguage = new CultureInfo("ja-JP"); 



If ja-JP isn't working for you either way, while the next-language key does, you could simulate the latter being pressed:

Code
Select All
keyboard.SendKey(MindFusion.UI.Wpf.Key.Lang); 



Unfortunately, the language change is asynchronous and you can't check immediately what is the current language after sending the key. You could listen to InputLanguageManager.InputLanguageChanged event instead, and cycle from there until active language is reported as ja-JP.

Code
Select All
InputLanguageManager.Current.InputLanguageChanged += OnInputLanguageChanged;

void OnInputLanguageChanged(object sender, InputLanguageEventArgs e)
{
    Debug.WriteLine(e.NewLanguage);
} 



Quote:
I already have the Japanese language pack


You don't have to install language packs btw, just control panel -> Languages -> Add Language, and then you can clear all checkboxes to install just the keyboard layout.

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