Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » NUM_LOCK
NUM_LOCK [message #881733] Tue, 05 June 2012 03:10 Go to next message
Eclipse UserFriend
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 08:04 Go to previous messageGo to next message
Eclipse UserFriend
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 05:57 Go to previous message
Eclipse UserFriend
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 05:57] by 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: Mon Jul 14 00:45:32 EDT 2025

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

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

Back to the top