- 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 spreadsheet component for Java Swing. We have released our Java Swing Pack.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Set single key color
Read 873 times

Jim   Offline
YaBB Newbies
*
Posts: 1
I Love MindFusion!


   
     
 
Set single key color
May 20th, 2016 at 8:34pm
 
Is possible to change background (also hover & pressed background too) color of a single key on the keyboard at runtime?

Also, how to lock to capslock on a shift doubleclick/doublepress?
 
 
 
IP Logged    
 
     

Slavcho   Offline
YaBB Moderator
*****
Posts: 1103
Gender: male
tech.support


   
     
 
Re: Set single key color
Reply #1 - May 21st, 2016 at 6:51am
 
Hi,

At this time painting keys in distinct colors can be done only through a custom KeyTemplate, for example this paints a red Enter key -

Code:
class MyTemplate : KeyTemplate
{
	public MyTemplate()
	{
		defaultBrush = Background;
	}

	GradientBrush defaultBrush;

	public override void Draw(Graphics g, Key key, Mode mode, Font font)
	{
		if (key.Equals(Key.ENTER))
		{
			Background = new GradientBrush(
				new List<Color> { Color.Red },
				new List<float> { 0f }, 0f);
			base.Draw(g, key, mode, font);
			Background = defaultBrush;
			return;
		}

		base.Draw(g, key, mode, font);
	}
}

kb.KeyTemplate = new MyTemplate(); 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

Slavcho   Offline
YaBB Moderator
*****
Posts: 1103
Gender: male
tech.support


   
     
 
Re: Set single key color
Reply #2 - May 21st, 2016 at 7:05am
 
Quote:
Also, how to lock to capslock on a shift doubleclick/doublepress?


One way I can see to enable CapsLocks is calling Key.CAPSLOCK.Send method. There's no Key-DoubleClicked event available, instead you might hadle KeyPressed and check the time to determine if it's a double click -

Code:
void OnKeyPressed(object sender, VirtualKeyEventArgs e)
{
	if (e.Key.Equals(Key.SHIFT))
	{
		if (lastClick != null &&
			DateTime.Now - lastClick.Value < TimeSpan.FromSeconds(0.5))
		{
			Key.CAPSLOCK.Send(true);
		}

		lastClick = DateTime.Now;
	}
} 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print