/** * Determine if the key event represents a "submit" action * (<modifier>+Enter). * * @param event * @return true, if it means submit, false otherwise */ public static boolean isSubmitKeyEvent(KeyEvent event) { return (event.stateMask & SWT.MODIFIER_MASK) != 0 && event.keyCode == SUBMIT_KEY_STROKE.getNaturalKey(); }
/** * Given a key stroke, this method provides the equivalent SWT accelerator * value. The functional inverse of * <code>convertAcceleratorToKeyStroke</code>. * * @param keyStroke * The key stroke to convert; must not be <code>null</code>. * @return The SWT accelerator value */ public static final int convertKeyStrokeToAccelerator( final KeyStroke keyStroke) { return keyStroke.getModifierKeys() + keyStroke.getNaturalKey(); }
/** * Given a key stroke, this method provides the equivalent SWT accelerator * value. The functional inverse of * <code>convertAcceleratorToKeyStroke</code>. * * @param keyStroke * The key stroke to convert; must not be <code>null</code>. * @return The SWT accelerator value */ public static final int convertKeyStrokeToAccelerator( final KeyStroke keyStroke) { return keyStroke.getModifierKeys() + keyStroke.getNaturalKey(); }
/** * Given a key stroke, this method provides the equivalent SWT accelerator * value. The functional inverse of * <code>convertAcceleratorToKeyStroke</code>. * * @param keyStroke * The key stroke to convert; must not be <code>null</code>. * @return The SWT accelerator value */ public static final int convertKeyStrokeToAccelerator( final KeyStroke keyStroke) { return keyStroke.getModifierKeys() + keyStroke.getNaturalKey(); }
@Override public String format(final KeyStroke keyStroke) { final String keyDelimiter = getKeyDelimiter(); // Format the modifier keys, in sorted order. final int modifierKeys = keyStroke.getModifierKeys(); final int[] sortedModifierKeys = sortModifierKeys(modifierKeys); final StringBuffer stringBuffer = new StringBuffer(); if (sortedModifierKeys != null) { for (int i = 0; i < sortedModifierKeys.length; i++) { final int modifierKey = sortedModifierKeys[i]; if (modifierKey != KeyStroke.NO_KEY) { stringBuffer.append(format(modifierKey)); stringBuffer.append(keyDelimiter); } } } // Format the natural key, if any. final int naturalKey = keyStroke.getNaturalKey(); if (naturalKey != 0) { stringBuffer.append(format(naturalKey)); } return stringBuffer.toString(); }
@Override public void keyPressed(KeyEvent e) { if (e.character == 0x1B) { // ESC dispose(); } else { if(e.keyCode == invokingKeystroke.getNaturalKey() && e.stateMask == invokingKeystroke.getModifierKeys()) { changeOutlineMode(); e.doit = false; } } } });
@Override public String format(final KeyStroke keyStroke) { final String keyDelimiter = getKeyDelimiter(); // Format the modifier keys, in sorted order. final int modifierKeys = keyStroke.getModifierKeys(); final int[] sortedModifierKeys = sortModifierKeys(modifierKeys); final StringBuilder stringBuffer = new StringBuilder(); if (sortedModifierKeys != null) { for (final int modifierKey : sortedModifierKeys) { if (modifierKey != KeyStroke.NO_KEY) { stringBuffer.append(format(modifierKey)); stringBuffer.append(keyDelimiter); } } } // Format the natural key, if any. final int naturalKey = keyStroke.getNaturalKey(); if (naturalKey != 0) { stringBuffer.append(format(naturalKey)); } return stringBuffer.toString(); }
public String format(final KeyStroke keyStroke) { final String keyDelimiter = getKeyDelimiter(); // Format the modifier keys, in sorted order. final int modifierKeys = keyStroke.getModifierKeys(); final int[] sortedModifierKeys = sortModifierKeys(modifierKeys); final StringBuffer stringBuffer = new StringBuffer(); if (sortedModifierKeys != null) { for (int i = 0; i < sortedModifierKeys.length; i++) { final int modifierKey = sortedModifierKeys[i]; if (modifierKey != KeyStroke.NO_KEY) { stringBuffer.append(format(modifierKey)); stringBuffer.append(keyDelimiter); } } } // Format the natural key, if any. final int naturalKey = keyStroke.getNaturalKey(); if (naturalKey != 0) { stringBuffer.append(format(naturalKey)); } return stringBuffer.toString(); }
/** * Gets an instance of <code>KeySequence</code> given a new-style key * sequence. * * @param newKeySequence * The new-style key sequence to convert into a legacy key * sequence; must not be <code>null</code>. * @return a key sequence; never <code>null</code>. */ public static KeySequence getInstance( final org.eclipse.jface.bindings.keys.KeySequence newKeySequence) { final org.eclipse.jface.bindings.keys.KeyStroke[] newKeyStrokes = newKeySequence .getKeyStrokes(); final int newKeyStrokesCount = newKeyStrokes.length; final List legacyKeyStrokes = new ArrayList(newKeyStrokesCount); for (int i = 0; i < newKeyStrokesCount; i++) { final org.eclipse.jface.bindings.keys.KeyStroke newKeyStroke = newKeyStrokes[i]; legacyKeyStrokes.add(SWTKeySupport .convertAcceleratorToKeyStroke(newKeyStroke .getModifierKeys() | newKeyStroke.getNaturalKey())); } return new KeySequence(legacyKeyStrokes); }
if ((currentStroke != null) && (!currentStroke.isComplete())) { int modifierKeys = currentStroke.getModifierKeys(); final int naturalKey = stroke.getNaturalKey(); modifierKeys |= stroke.getModifierKeys(); keyStrokes[index] = KeyStroke.getInstance(modifierKeys, naturalKey);
if ((currentStroke != null) && (!currentStroke.isComplete())) { int modifierKeys = currentStroke.getModifierKeys(); final int naturalKey = stroke.getNaturalKey(); modifierKeys |= stroke.getModifierKeys(); keyStrokes[index] = KeyStroke.getInstance(modifierKeys, naturalKey);
if ((currentStroke != null) && (!currentStroke.isComplete())) { int modifierKeys = currentStroke.getModifierKeys(); final int naturalKey = stroke.getNaturalKey(); modifierKeys |= stroke.getModifierKeys(); keyStrokes[index] = KeyStroke.getInstance(modifierKeys, naturalKey);
.getNaturalKey() == e.character) || (triggerKeyStroke.getNaturalKey() == e.keyCode && ((triggerKeyStroke .getModifierKeys() & e.stateMask) == triggerKeyStroke .getModifierKeys()))) {
@Override public int getAccelerator() { final String commandId = getActionDefinitionId(); final IBindingService bindingService = serviceLocator .getService(IBindingService.class); final TriggerSequence triggerSequence = bindingService .getBestActiveBindingFor(commandId); if (triggerSequence instanceof KeySequence) { final KeySequence keySequence = (KeySequence) triggerSequence; final KeyStroke[] keyStrokes = keySequence.getKeyStrokes(); if (keyStrokes.length == 1) { final KeyStroke keyStroke = keyStrokes[0]; return keyStroke.getModifierKeys() | keyStroke.getNaturalKey(); } } return 0; }
.getNaturalKey() == e.character) || (triggerKeyStroke.getNaturalKey() == e.keyCode && ((triggerKeyStroke .getModifierKeys() & e.stateMask) == triggerKeyStroke .getModifierKeys()))) {
if ((SWT.NUM_LOCK == stroke.getNaturalKey()) || (SWT.CAPS_LOCK == stroke.getNaturalKey()) || (SWT.SCROLL_LOCK == stroke.getNaturalKey())) { return keyStrokes;
.getNaturalKey() == e.character) || (triggerKeyStroke.getNaturalKey() == e.keyCode && ((triggerKeyStroke .getModifierKeys() & e.stateMask) == triggerKeyStroke .getModifierKeys()))) {
if ((SWT.NUM_LOCK == stroke.getNaturalKey()) || (SWT.CAPS_LOCK == stroke.getNaturalKey()) || (SWT.SCROLL_LOCK == stroke.getNaturalKey())) { return keyStrokes;
if ((SWT.NUM_LOCK == stroke.getNaturalKey()) || (SWT.CAPS_LOCK == stroke.getNaturalKey()) || (SWT.SCROLL_LOCK == stroke.getNaturalKey())) { return keyStrokes;
@Override public void keyPressed(KeyEvent e) { if (e.keyCode == 0x0D) // return gotoSelectedElement(); if (e.keyCode == SWT.ARROW_DOWN) treeViewer.getTree().setFocus(); if (e.keyCode == SWT.ARROW_UP) treeViewer.getTree().setFocus(); if (e.character == 0x1B) // ESC dispose(); if(e.keyCode == invokingKeystroke.getNaturalKey() && e.stateMask == invokingKeystroke.getModifierKeys()) { changeOutlineMode(); e.doit = false; } } });