Java Code Examples for com.google.gwt.user.client.Event#getAltKey()

The following examples show how to use com.google.gwt.user.client.Event#getAltKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventTranslator.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
private static KeyEvent toKeyEvent(Event e) {
  Key key = KeyCodeMapper.getKey(e.getKeyCode());

  Set<ModifierKey> modifiers = new HashSet<>();
  if (e.getCtrlKey()) {
    modifiers.add(ModifierKey.CONTROL);
  }
  if (e.getAltKey()) {
    modifiers.add(ModifierKey.ALT);
  }
  if (e.getShiftKey()) {
    modifiers.add(ModifierKey.SHIFT);
  }
  if (e.getMetaKey()) {
    modifiers.add(ModifierKey.META);
  }
  return new KeyEvent(key, (char) e.getCharCode(), modifiers);
}
 
Example 2
Source File: CubaSourceCodeEditorWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN
            && event.getKeyCode() == KeyCodes.KEY_ENTER
            && !event.getAltKey()
            && !event.getShiftKey()
            && !event.getCtrlKey()) {
        event.stopPropagation();
        return;
    }

    super.onBrowserEvent(event);
}
 
Example 3
Source File: EventWrapper.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * @return A string describing which modifier keys were pressed,
 *        and whether this was a repeat event,  e.g., " shift ctrl"
 */
@SuppressWarnings("deprecation")
public static String modifiers(Event event) {
  // repeat is deprecated, but useful for debugging
  return (event.getAltKey() ? " alt" : "")
  + (event.getShiftKey() ? " shift" : "")
  + (event.getCtrlKey() ? " ctrl" : "")
  + (event.getMetaKey() ? " meta" : "")
  + ((event.getTypeInt() == Event.ONKEYDOWN) && event.getRepeat() ? " repeat" : "");
}
 
Example 4
Source File: EventWrapper.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * @return A string describing which modifier keys were pressed,
 *        and whether this was a repeat event,  e.g., " shift ctrl"
 */
@SuppressWarnings("deprecation")
public static String modifiers(Event event) {
  // repeat is deprecated, but useful for debugging
  return (event.getAltKey() ? " alt" : "")
  + (event.getShiftKey() ? " shift" : "")
  + (event.getCtrlKey() ? " ctrl" : "")
  + (event.getMetaKey() ? " meta" : "")
  + ((event.getTypeInt() == Event.ONKEYDOWN) && event.getRepeat() ? " repeat" : "");
}
 
Example 5
Source File: CubaPopupButtonWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected boolean isShortcut(Event event) {
    return event.getShiftKey() || event.getAltKey() || event.getCtrlKey() || event.getMetaKey();
}
 
Example 6
Source File: CubaButtonWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected boolean isShortcut(Event event) {
    return event.getShiftKey() || event.getAltKey() || event.getCtrlKey() || event.getMetaKey();
}
 
Example 7
Source File: Tools.java    From cuba with Apache License 2.0 4 votes vote down vote up
public static boolean isAnyModifierKeyPressed(Event event) {
    return (event.getShiftKey()
            || event.getAltKey()
            || event.getCtrlKey()
            || event.getMetaKey());
}