Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Listening to the arrow keys
Listening to the arrow keys [message #465209] Thu, 08 December 2005 08:02 Go to next message
Eclipse UserFriend
Originally posted by: igor.dawg.gmail.com

hello,

I'm havin a problem. I need my application to listen to the 4 arrow keys
and i dont know how i should create those 4 listeners. Do i have to add
the listeners to the Shell, Displey or somewhere else? I dont
know....please help....

Thanks

Igor ROhal
Re: Listening to the arrow keys [message #465287 is a reply to message #465209] Thu, 08 December 2005 14:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: igor.dawg.gmail.com

Hmmm..... Listener(SWT.KeyDown) works fine, but I can't get to work
Listener(SWT.ARROW_DOWN(UP/LEFT/RIGHT))....could anyone please help me?
igor rohal
Re: Listening to the arrow keys [message #465340 is a reply to message #465287] Fri, 09 December 2005 08:30 Go to previous message
Yves Harms is currently offline Yves HarmsFriend
Messages: 80
Registered: July 2009
Member
Igor Rohal wrote:
> Hmmm..... Listener(SWT.KeyDown) works fine, but I can't get to work
> Listener(SWT.ARROW_DOWN(UP/LEFT/RIGHT))....could anyone please help me?
> igor rohal
>

yourControl.addKeylistener(new KeyListener(){

public void keyPressed(KeyEvent e) {
switch(e.keyCode){
case SWT.ARROW_DOWN:{
//do sth.
break;
}
//other cases here ...
}
);

Note: yourControl must have focus to get any key events.
An alternative is display.addFilter(), in that case you would always get
all key events of your application (regardless if yourControl has focus
or is visible at all)

Further reading: the book "SWT: The standard Widget Tookit"

Yves
Previous Topic:SWT accelerator key behavior for Buttons
Next Topic:Error executing standalone SWT application
Goto Forum:
  


Current Time: Sat Dec 14 05:00:27 GMT 2019

Powered by FUDForum. Page generated in 0.01911 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top