Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » NUM_LOCK
NUM_LOCK [message #881733] Tue, 05 June 2012 07:10 Go to next message
Gerald Radix is currently offline Gerald RadixFriend
Messages: 9
Registered: April 2012
Junior Member
Hi,

How does one go about determining the status of Caps Lock and Num Lock in SWT ?
Re: NUM_LOCK [message #881870 is a reply to message #881733] Tue, 05 June 2012 12:04 Go to previous messageGo to next message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 29
Registered: March 2011
Location: Brazil
Junior Member
You get them this way:

boolean caps = Toolkit.getDefaultToolkit().getLockingKeyState( java.awt.event.KeyEvent.VK_CAPS_LOCK );
boolean num = Toolkit.getDefaultToolkit().getLockingKeyState( java.awt.event.KeyEvent.VK_NUM_LOCK );
boolean scroll = Toolkit.getDefaultToolkit().getLockingKeyState( java.awt.event.KeyEvent.VK_SCROLL_LOCK );


You may change any of them by doing this:

Toolkit.getDefaultToolkit().setLockingKeyState( java.awt.event.KeyEvent.VK_CAPS_LOCK, boolean );


Mário Marinato
From Brazil
Re: NUM_LOCK [message #882361 is a reply to message #881733] Wed, 06 June 2012 09:57 Go to previous message
Lakshmi ShanmugamFriend
Messages: 274
Registered: July 2009
Location: India
Senior Member
Hi,

You can't directly determine the state of Numlock & Capslock using SWT. (there is a bug request for it -- https://bugs.eclipse.org/bugs/show_bug.cgi?id=71538).
But, inside the Key Listener you can determine if the key was typed in the numeric keypad with Numlock ON. The event.keyLocation is set to KEYPAD and the event.keyCode is set to the SWT.KEYPAD_* constants.


Lakshmi P Shanmugam

[Updated on: Wed, 06 June 2012 09:57]

Report message to a moderator

Previous Topic:SWTError: No more handles in Eclipse 3.7.2 SDK on AIX 7.1
Next Topic:Drawing an image on a double buffered canvas
Goto Forum:
  


Current Time: Wed Nov 26 19:11:03 GMT 2014

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

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