Example usage for org.eclipse.jface.bindings.keys SWTKeySupport convertEventToUnshiftedModifiedAccelerator

List of usage examples for org.eclipse.jface.bindings.keys SWTKeySupport convertEventToUnshiftedModifiedAccelerator

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys SWTKeySupport convertEventToUnshiftedModifiedAccelerator.

Prototype

public static final int convertEventToUnshiftedModifiedAccelerator(final Event event) 

Source Link

Document

Converts the given event into an SWT accelerator value -- considering the modified character without the shift modifier.

Usage

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.
 * /*w w  w. j av  a2s  . c o  m*/
 * @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/*from w  w  w . j  av a  2s.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;
}