XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 10th, 2025, 2:04 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ArrowKeyCommands
PostPosted: September 14th, 2013, 6:15 am 
Offline
User avatar

Joined: September 7th, 2013, 11:00 am
Posts: 6
How do I make it so that if I press one of the arrow keys on my keyboard the image would change?
This is my code so far:
Code:
function widgetArrowKeyCommand1()
{
  myimage.src = "image1.png";
}
function widgetArrowKeyCommand2()
{
  myimage.src = "image2.png";
}


Instead of the "ArrowKeyCommand1/2", There's something that I need to put (for each arrow key=4keys).
Not sure what it is, hope someone can help me out here.

Thanks! :lol:

_________________
Image


Top
 Profile  
 
 Post subject: Re: ArrowKeyCommands
PostPosted: September 19th, 2013, 4:47 pm 
Offline
User avatar

Joined: September 7th, 2013, 11:00 am
Posts: 6
any ideas :0?

_________________
Image


Top
 Profile  
 
 Post subject: Re: ArrowKeyCommands
PostPosted: November 2nd, 2013, 4:05 pm 
Offline

Joined: October 26th, 2013, 8:17 am
Posts: 362
i'm just a user of Xwidget and sharing my experience about it:
===================
FindOut Keyboard Key Codes:

To use the keyboard keys you could use OnKeyDown Event; but it only works for Edit boxes for me when it has Typing focused to it

*Remember to use below code you should goto object edit1 and in Functions Tab set the OnKeyDown Function to edit1OnKeyDown
*and you need to create Text1 Object to see Output

Code:
function edit1OnKeyDown(Sender,Key,KeyChar,Shift)
{
  text1.Text=Key   
  //to get Charecters Key(a,b,c,...) Output use [KeyChar] after equal (text1.Text=KeyChar)
  //to get other Keys (Ctrl,alt,arrowkeys,winkey,...) Output use [Key] after equal (text1.Text=Key)
}


[text1] is name of object i create for test the Output
[KeyChar] & [Key] are variables in KeyDown Function that recieve Key Codes

===============
using Keyboard Key Codes:

after you find out the key Output you could use it this way:

Code:
function edit1OnKeyDown(Sender,Key,KeyChar,Shift)
{
  //Key Codes may be different for your keyboard so find it yourself
  if(Key=="37")  //37 is ArrowLeft //38 is ArrowUp //39 is ArrowRight //40 is ArrowDown
  {
    text1.Text="Hello World"  //Replace this line with your own Commands [myimage.src = "image1.png";]
  }
}


=========================
using Mouse Button Codes:

you could use same way for Mouse Buttons plus you could use it for all objects
for this you should set OnMouseDown Function instead of OnKeyDown Function
and in the code you should use Button instead of Key

Code:
function edit1OnMouseDown(Sender,Button,Shift,X,Y)
{
  //Key Codes may be different for your Mouse so find it yourself
  if(Key=="2")  //2 is MiddleButton //1 is RightButton //0 is LeftButton
  {
    text1.Text="Hello World"  //Replace this line with your own Commands [myimage.src = "image1.png";]
  }
}


=========================


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 38 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group