Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Key (Read 2086 times)
Ken
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Mar 3rd, 2022
Custom Key
Mar 3rd, 2022 at 3:39pm
Print Post  
I'm trying to create a custom template with a key on the keyboard that is only used for the @ symbol.
Is there a way to accomplish this?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Custom Key
Reply #1 - Mar 3rd, 2022 at 4:11pm
Print Post  
Assuming you also don't want the regular @ key to send 2 depending on Shift state, you could make that key the only UnicodeKey instance in your custom layout, and then create a global UnicodeKey template in Xaml -

Code
Select All
<DataTemplate DataType="{x:Type vk:UnicodeKey}">
	<ContentControl HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
		<TextBlock Text="{Binding Character}"/>
	</ContentControl>
</DataTemplate>
 



Otherwise if you only need to use different colors or font for @, it should also be possible to use a data trigger in the template that checks for @ value and applies respective property setters.

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


I Love MindFusion!

Posts: 2
Joined: Mar 3rd, 2022
Re: Custom Key
Reply #2 - Mar 3rd, 2022 at 4:23pm
Print Post  
Sorry, I'm new to windows programming with WPF so some of that wasn't exactly clear to me. 
However; What I'm trying to accomplish is a keyboard that has the normal 2/@ key on it, but I want to add a key that only types the @ key regardless of the shift state.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Custom Key
Reply #3 - Mar 3rd, 2022 at 4:48pm
Print Post  
You could use KeyboardCreator to add UnicodeKey to your custom layout, setting its Character to @. Load the layout file by calling -

Code
Select All
keyboard.TemplateLayout = KeyboardLayout.Create(filePath); 



Add the template to a resource dictionary somewhere in your Xaml -

Code
Select All
<Window ...>
	<Window.Resources>
		<DataTemplate DataType="{x:Type vk:UnicodeKey}">
			<ContentControl HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
				<TextBlock Text="{Binding Character}"/>
			</ContentControl>
		</DataTemplate>
	</Window.Resources> 



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