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

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
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: 275
Registered: July 2009
Location: India
Senior Member

You can't directly determine the state of Numlock & Capslock using SWT. (there is a bug request for it --
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:How to print contents of a scrolledComposite?
Next Topic:SWT Browser and PDF
Goto Forum:

Current Time: Wed Sep 20 16:37:23 GMT 2017

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

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