Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Differing custom layout (Read 3313 times)
ErikJ
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: Mar 26th, 2019
Differing custom layout
Mar 26th, 2019 at 8:07pm
Print Post  
I have created a custom layout and found when running some of the keys are altered unexpectedly. Not sure what I am doing wrong. I have attached the layout xml file (renamed with .txt extension) as well as you can see screenshots of designer vs runtime.

Key differences are the "\|" key above enter turns into "'"" key and the "/?" key next to right shift altogether disappears. The "\|" key appears twice next to A and Z.
  

KeyLayout_UserReg.txt ( 12 KB | 214 Downloads )
designer.png ( 21 KB | 205 Downloads )
designer.png
runtime.png ( 14 KB | 208 Downloads )
runtime.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Differing custom layout
Reply #1 - Mar 27th, 2019 at 8:59am
Print Post  
RegularKeys only store a virtual key code and the characters they synthesize (and draw as labels) depend on current Windows' keyboard language. For example I can see cyrillic Ю letters in place of your \| or '" because they share same virtual key code Smiley To make sure your designs match target input language, select the same from the Language combo in Keyboard Creator. If you want the keys to be independent from current language, try using UnicodeKey instances instead.

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


I Love MindFusion!

Posts: 9
Joined: Mar 26th, 2019
Re: Differing custom layout
Reply #2 - Mar 27th, 2019 at 5:13pm
Print Post  
I am still puzzled as to why the keys seem to have been relocated. Why is the \| key duplicated next to A and Z? If it was just a character display issue I would expect the layout to be the same and just the key text to be altered.

Is there a quick/easy method to convert all virtual keys to unicode keys? It looks like in the designer I would need to manually create my own layout from scratch as the default layout starts with the literal keys and the Unicode Keys tab only has a single example key.

Is there any additional runtime information I could retrieve that will tell what language the program is using versus what the keyboard expects?

I plan to eventually implement automatic Shift/Cap toggling (as discussed in this post) but I didn't want to start that quite yet since I wanted to first understand and get past this key relocation issue.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3204
Joined: Oct 19th, 2005
Re: Differing custom layout
Reply #3 - Mar 28th, 2019 at 6:08am
Print Post  
If you are setting TemplateLayout, and keep all the regular keys, it actually replaces the regular keys block with ones from standard Windows keyboard layouts for the language when AutoFill is enabled (e.g. azerty / qwerty, umlauted characters, punctuation keys, etc). Set AutoFill = false and it will show your expected layout without modifications.

There's nothing built-in to convert keys, but if you need it you could create a new layout instance from code using the positions of keys loaded from the file -

Code
Select All
var layout = KeyboardLayout.Create("KeyLayout_UserReg.xml");
var newLayout = new KeyboardLayout();
foreach (var key in layout.Keys)
{
    var rk = key as RegularKey;
    if (rk != null)
    {
        var uk = new UnicodeKey();
        uk.Left = rk.Left;
        uk.Top = rk.Top;
        uk.Width = rk.Width;
        uk.Height = rk.Height;
        uk.Character = rk.LowerCase[0];
        newLayout.Keys.Add(uk);
    }
    else
    {
        newLayout.Keys.Add(key);
    }
}
kb.TemplateLayout = newLayout;
 



This misses the shift characters of punctuation keys though, you might need to derive from UnicodeKey to specify yourself instead of relying on current automatic Lower/Upper methods of the char type.

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


I Love MindFusion!

Posts: 9
Joined: Mar 26th, 2019
Re: Differing custom layout
Reply #4 - Mar 28th, 2019 at 6:20pm
Print Post  
Thank you Slavcho! Setting the AutoFill property to False got me what I was after.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint