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: 30
Registered: March 2011
Location: Brazil
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 );
Re: NUM_LOCK [message #882361 is a reply to message #881733] Wed, 06 June 2012 09:57 Go to previous message
Lakshmi ShanmugamFriend
Messages: 275
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.

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

Report message to a moderator

Previous Topic:How to print contents of a scrolledComposite?
Next Topic:SWT Browser and PDF
Goto Forum:
  


Current Time: Mon Mar 27 14:42:11 GMT 2017

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

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