What is the SWT key constant for the menu key - java

Does anyone know what the key constant in SWT is for the menu key on the keyboard (right next to right-Ctrl)?
This key has a virtual key code of 0x5D (93). I need it for correct key combination detection.

There seems to be no constant defined for the Menu key.
In order to detect if a context menu was opened by mouse or by keyboard, you should add a MenuDetectListener. The detail field of its MenuDetectEvent is either SWT.MENU_MOUSE or SWT.MENU_KEYBOARD.

Related

Key binding for SWT Text

I have a dialog(org.eclipse.jface.dialogs.Dialog) containing a Text(org.eclipse.swt.widgets.Text) field. I want to add key binding.
For example: Once dialog is open when user press key 'Ctrl + E' some changes need to be performed in Text field.
How to achieve this using key binding ?

How to have Eclipse intellisense autocomplete member names?

When I type in a method name partially, Eclipse intellisense shows me the list of suggestions, but how do I select one of them using only the keyboard?
I tried pressing the Tab key, the Enter key and the Space bar, but all to no avail. It appears that the only way I can get to select one of the names from the list of suggestions is to use the mouse. This is very irritating.
Is there a keyboard short-cut to selecting a name from the intellisense suggestions?
Type in some part of the expression, use the arrow keys to navigate through the suggestions offered by intellisense. And then hit the Enter key to select the chosen expression, dismiss the pop-ups and have the selected expression appear in the editor in place of your partially typed expression.
Do not hit the tab key before making a selection as that moves focus away from the suggestions window.

Weird behavior of keyboard events in Java

When I press "Delete" button on the keyboard, program gets three events - KEY_PRESSED, KEY_TYPED, and KEY_RELEASED. The problem is, in KEY_PRESSED and KEY_RELEASED, parameter "keyCode" is set, but in the KEY_TYPED it is not (in fact, there no meaningful info in that event). With F5 key, it is even funnier - KEY_PRESSED and KEY_RELEASED are registered, but KEY_TYPED never occurs.
The listener was added via Toolkit.getDefaultToolkit().addAWTEventListener(). Using JDK 6.26.
What could be my problem?
EDIT:
Here are the events that happen when Delete key is pressed:
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=127,keyText=Delete,keyChar=Delete,keyLocation=KEY_LOCATION_STANDARD,rawCode=119,primaryLevelUnicode=127,scancode=0] on javax.swing.JButton[,0,0,61x30,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.synth.SynthBorder#50f38cf0,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.ImageIcon#6ae2d0b2,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=SVG,defaultCapable=false]
java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=Delete,keyLocation=KEY_LOCATION_UNKNOWN,rawCode=0,primaryLevelUnicode=127,scancode=0] on javax.swing.JButton[,0,0,61x30,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.synth.SynthBorder#50f38cf0,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.ImageIcon#6ae2d0b2,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=SVG,defaultCapable=false]
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=127,keyText=Delete,keyChar=Delete,keyLocation=KEY_LOCATION_STANDARD,rawCode=119,primaryLevelUnicode=127,scancode=0] on javax.swing.JButton[,0,0,61x30,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.synth.SynthBorder#50f38cf0,flags=288,maximumSize=,minimumSize=,preferredSize=,defaultIcon=javax.swing.ImageIcon#6ae2d0b2,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=true,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=SVG,defaultCapable=false]
better would be implements KeyBindings
part of keyboard are reserved Keys for built-in JComponent funcionality, more informations from #camickrs UIManager Defaults
depends of reason(s) why you needed implents KeyListener, because for there are lots of another Listeners for various JComponent, that should be filtering or register text changes inside
some of JComponent Models generated Events from Mouse and Keyboard input
From the JavaDoc The "key typed" event. This event is generated when a character is entered. In the simplest case, it is produced by a single key press. Often, however, characters are produced by series of key presses, and the mapping from key pressed events to key typed events may be many-to-one or many-to-many.
You are trying to get the F5 key which is probably not registered as a character being entered. By using the KEY_RELEASED you will consistently get the result you are looking for and the API is behaving as expected.
Key typed events ALWAYS generate '0' as the key code. Look up the method getKeyChar() instead, or (as has been suggested) listen for keyReleased() instead.
getKeyChar(): http://goo.gl/ajH03

What are `VK_META` and `META_MASK` in the Java Robot class?

What are VK_META and META_MASK in the Java Robot class? Any example that explains what they are or what they do would be very helpful.
Also, VK_META gives me an invalid keycode error on my Windows 7 PC.
VK_META and META_MASK are defined in KeyEvent and InputEvent classes. They both define the META key as a standalone key pressed and as a modifier used pressing another key respectively.
The META key is a key used in old keyboards and now can be emulated using the Windows Key.
Robot class allows to simulate key strokes (pressed, released, typed) and mouse movement, "acting" as a user using the keyboard and mouse. When you use the robot class, you define the sequence of "actions" to simulate, mouse movements and keyboard usage. If you want to simulate the META key pressed or used as a modifier, need to pass the keyCode and these two constants define the keyCode for META typed and modifier.
You can have problems using this key depending some factors, such your keyboard layout, keyboard configuration, operating system...
If you have problem, try avoid using this key except you need to simulate the Windows (PC) or Command (Mac) key.

InputEvent modifiers key

When I try to get (isAltGraphDown) if the ALT GR key is pressed when I click a button Java returns always false also if it's pressed.
Instead with e.getModifiersExText(e.getModifiersEx()) it returns Ctrl+Alt !!!
What's the problem?
and If I wanted to know if a user pressed a right Shift key?
When I was on the jEdit mailing list I saw a lot of these types of issues, usually when using non-US keyboard layouts. Occasionally other software on the system can also cause trouble, but most often it's a JVM bug. What keyboard layout are you using?

Categories

Resources