List of usage examples for org.eclipse.jface.bindings.keys SWTKeySupport convertEventToModifiedAccelerator
public static final int convertEventToModifiedAccelerator(final Event event)
Converts the given event into an SWT accelerator value -- considering the modified character with the shift modifier.
From source file:org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.java
License:Open Source License
/** * Generates any key strokes that are near matches to the given event. The first such key stroke * is always the exactly matching key stroke. * /*from www. ja v a 2s.c om*/ * @param event * The event from which the key strokes should be generated; must not be * <code>null</code>. * @return The set of nearly matching key strokes. It is never <code>null</code>, but may be * empty. */ public static List<KeyStroke> generatePossibleKeyStrokes(Event event) { final List<KeyStroke> keyStrokes = new ArrayList<KeyStroke>(3); /* * If this is not a keyboard event, then there are no key strokes. This can happen if we are * listening to focus traversal events. */ if ((event.stateMask == 0) && (event.keyCode == 0) && (event.character == 0)) { return keyStrokes; } // Add each unique key stroke to the list for consideration. final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator)); // We shouldn't allow delete to undergo shift resolution. if (event.character == SWT.DEL) { return keyStrokes; } final int secondAccelerator = SWTKeySupport.convertEventToUnshiftedModifiedAccelerator(event); if (secondAccelerator != firstAccelerator) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator)); } final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event); if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator)); } return keyStrokes; }
From source file:org.eclipse.ui.internal.keys.WorkbenchKeyboard.java
License:Open Source License
/** * Generates any key strokes that are near matches to the given event. The * first such key stroke is always the exactly matching key stroke. * * @param event//ww w. j a v a 2 s .c om * The event from which the key strokes should be generated; must * not be <code>null</code>. * @return The set of nearly matching key strokes. It is never * <code>null</code>, but may be empty. */ public static List generatePossibleKeyStrokes(Event event) { final List keyStrokes = new ArrayList(3); /* * If this is not a keyboard event, then there are no key strokes. This * can happen if we are listening to focus traversal events. */ if ((event.stateMask == 0) && (event.keyCode == 0) && (event.character == 0)) { return keyStrokes; } // Add each unique key stroke to the list for consideration. final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator)); // We shouldn't allow delete to undergo shift resolution. if (event.character == SWT.DEL) { return keyStrokes; } final int secondAccelerator = SWTKeySupport.convertEventToUnshiftedModifiedAccelerator(event); if (secondAccelerator != firstAccelerator) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator)); } final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event); if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator)); } return keyStrokes; }