Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Keyboard Culture (Read 29772 times)
Diego Vazquez
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Keyboard Culture
Aug 4th, 2016 at 9:33am
Print Post  
Hello
I am working in the multi-culture application and we are using the your Virutalkeyboard.

So basically the virtualkey 192:
if the input method is spanisch will show ñ
if the input method is german will show ö

what I need to achieve is changing the keyboard culture somehow, but without changing the Input method in the Operative System, Is this possible? or in order to show a Spanish layout I muss to have the input method Spanish installed?

Can I somehow override the KEyboard OnRendering and just change the content / capslock content etc?

Thanks in advanced
Diego
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keyboard Culture
Reply #1 - Aug 4th, 2016 at 2:03pm
Print Post  
Hi,

From what I can see in the code, the CurrentCulture property automatically sets CurrentThread.CurrentCulture to same value. I'm not sure of the original author's intentions, I guess one reason is to get the character label for respective virtual key in current culture. The other one being that when users click the key, it sends a virtual-key code to currently focused control (e.g. 192), and to make sure the key's label matches how the virtual code is interpreted, the target control must use same culture as the keyboard.

Now if you set the RegularKey.Content property to a string containing a single character, the key will be actually sent as a WM_CHAR message (say ñ) rather than a virtual key code. You could use this to implement keyboard keys that always send same char independent from current culture, and to display a label that does not change with culture. Unfortunately that will disable built-in caps-lock and Shift handling. Instead you will have to change Content of such keys dynamically.

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


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #2 - Aug 4th, 2016 at 2:34pm
Print Post  
Hi, Thanks for your message.

Yes, I tried that option, but  unfortunately I need the caps-lock and the shift handing.

In the samples the keyboard layout in including all the symbols, and in my application as you see in the images with the black keys, is only showing the key, so I need to press shift or altGr to see symbols and the caps.
Is threre a way so set this layout ?

Thanks in advanced,
Diego
  

allsymbols.png ( 59 KB | 161 Downloads )
allsymbols.png
myapp.PNG ( 5 KB | 170 Downloads )
myapp.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keyboard Culture
Reply #3 - Aug 4th, 2016 at 6:26pm
Print Post  
Hi,

Quote:
Yes, I tried that option, but  unfortunately I need the caps-lock and the shift handing.


Well, it should not be hard to loop over all keys and set their Content to lowercase / uppercase of current char. I guess we could add this as a new mode for new version to avoid culture-dependencies.

Quote:
In the samples the keyboard layout in including all the symbols, and in my application as you see in the images with the black keys, is only showing the key, so I need to press shift or altGr to see symbols and the caps. Is threre a way so set this layout ?


Maybe check if your application isn't loading a custom DataTemplate for the RegularKey class?

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


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #4 - Aug 5th, 2016 at 6:49am
Print Post  
Hi Slavcho,
Thank you for your support!

Regarding the culture problem I guess I could write a converter based on the virtual key and the current language something like this
<TextBlock Text="{Binding Content, Converter={StaticResource LangConverter}}" that would change the content of Text for all the cases Upper, alter and lower

Do you think this is a good idea?

Best regards,
Diego
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keyboard Culture
Reply #5 - Aug 5th, 2016 at 7:57am
Print Post  
Hi Diego,

I'm not sure what you'll be converting. Is that TextBlock a part of  RegularKey's data template?

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


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #6 - Aug 5th, 2016 at 8:31am
Print Post  
1.
Yes, I ment to code a Converter for the bindings UpperCase, LowerCase and AlterCase that will return a value based on the application language.

<DataTemplate DataType="{x:Type fps:RegularKey}">
        <ContentControl  HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
            <!--<TextBlock Text="{Binding CurrentCase}"/>-->
            <StackPanel IsHitTestVisible="False" Visibility="Visible" x:Name="sp" >
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding UpperCase,  Converter={StaticResource LangConverter}}"/>
                    <TextBlock Text="{Binding AlterCase,  Converter={StaticResource LangConverter}}" Foreground="red" Margin="10 0 0 0"/>
                </StackPanel>
                <TextBlock Text="{Binding LowerCase,  Converter={StaticResource LangConverter}}" HorizontalAlignment="Right" Foreground="Black"/>
            </StackPanel>
        </ContentControl>
    </DataTemplate>

I will do a small proof of concept, and I will let u know if this works
  
Back to top
 
IP Logged
 
Diego Vazquez
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #7 - Aug 5th, 2016 at 9:15am
Print Post  
yes, you are right, I can just change the template but not the content of the key object.

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


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keyboard Culture
Reply #8 - Aug 5th, 2016 at 11:04am
Print Post  
The Key classes are not derived from DependencyObject so you won't be able to bind their properties and apply converters. Anyway, all Key instances are accessible through keyboard.Layout.Keys. So you could loop over them and assign to their Content value, depending on previous Content character or on VirtualKey code.

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


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #9 - Aug 5th, 2016 at 11:48am
Print Post  
Hi I am working with the version 4.2, and assigning a value to the content property does not change the content of the key in the  keyboard.
this for example does not change anything:

foreach (var key in vk.Layout.Keys)
            {
                    key.Content = "Ñ";
               
            }
The only way I found to change the content is  clearing the layout
vk.TemplateLayout.Keys.Clear();
adding the keys in runtime vk.TemplateLayout.Keys.add()
but as soon as I define a key as regular and I give a virtual code the content will be ignored

Any Ideas?
thanks!!!
Diego


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


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Keyboard Culture
Reply #10 - Aug 5th, 2016 at 1:24pm
Print Post  
I'm seeing attached with version 4.4. I'm afraid we don't even have v4.2 code, the original author hasn't provided us with sources of legacy versions.

Regards,
Slavcho
Mindfusion
  

keyboard.png ( 106 KB | 168 Downloads )
keyboard.png
Back to top
 
IP Logged
 
Diego Vazquez
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 7
Joined: Aug 4th, 2016
Re: Keyboard Culture
Reply #11 - Aug 5th, 2016 at 1:47pm
Print Post  
Thank you very much for your cooperation!

Yes there is definitely a difference between versions.
I found a way to achieve what I need but it is terrible.

Basically I Am creating the layout on runtime, in code no xml and depending on the state of Capslock and AltGr I am assigning the content.
Then I have a Data template converter that based on the virtual code sets the right character in the UI based on the application language.

It works and I can change the layout based without changing the input method.
the logic of capslock and alrGtr I will have to implement but I made a test and it works.

Thank you again for your support,
Diego



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