Java 类com.google.gwt.event.dom.client.KeyEvent 实例源码

项目:gerrit    文件:NpIntTextBox.java   
private void onKey(KeyEvent<?> event, int charCode, int keyCode) {
  if ('0' <= charCode && charCode <= '9') {
    if (event.isAnyModifierKeyDown()) {
      event.preventDefault();
    }
  } else {
    switch (keyCode) {
      case KeyCodes.KEY_BACKSPACE:
      case KeyCodes.KEY_LEFT:
      case KeyCodes.KEY_RIGHT:
      case KeyCodes.KEY_HOME:
      case KeyCodes.KEY_END:
      case KeyCodes.KEY_TAB:
      case KeyCodes.KEY_DELETE:
        break;

      default:
        // Allow copy and paste using ctl-c/ctrl-v,
        // or whatever the platform's convention is.
        if (!(event.isControlKeyDown() || event.isMetaKeyDown() || event.isAltKeyDown())) {
          event.preventDefault();
        }
        break;
    }
  }
}
项目:qafe-platform    文件:ActivityHelper.java   
private static void handleKeyInput(ComponentGVO componentGVO, EventListenerGVO eventGVO, KeyEvent event, String listenerType, NotifyHandler notifyHandler, String windowId, String context, AbstractActivity activity) {
    if (eventGVO.getParameterList() == null) {
        return;
    }
    Iterator<ParameterGVO> itrParameter = eventGVO.getParameterList().iterator();
    while (itrParameter.hasNext()) {
        ParameterGVO parameterGVO = itrParameter.next();
        if (parameterGVO == null) {
            continue;
        }
        if (KeyBoardHelper.isKeyInput(parameterGVO.getName(), parameterGVO.getValue(), event.getNativeEvent())) {
            UIObject widget = (UIObject)event.getSource();
            List<InputVariableGVO> inputVariables = eventGVO.getInputvariablesList();
            handleEvent(componentGVO, widget, eventGVO, event, listenerType, inputVariables, notifyHandler, windowId, context, activity);
            break;
        }
    }
}
项目:qafe-platform    文件:ComponentHelper.java   
public static void handleKeyConstraints(HasConstraints widget, String value, KeyEvent event, char charCode) {
    if (widget == null) {
        return;
    }
    if (isNonCharKeyPressed(event, charCode)) {
        return;
    }
    List<String> constraints = widget.getKeyConstraints();
    if ((constraints == null) || (constraints.size() == 0)) {
        return;
    }
    String newValue = value + charCode;
    if (newValue == null) {
        return;
    }
    for (String constraint : constraints) {
        if (newValue.matches(constraint)) {
            continue;
        }
        event.preventDefault();
        return;
    }
}
项目:opennmszh    文件:Code.java   
@SuppressWarnings("rawtypes")
public Code(KeyEvent event){
    if (event != null){
        if (event instanceof KeyPressEvent){
            kP_Event = (KeyPressEvent)event;
        } else if (event instanceof KeyDownEvent){
            kD_Event = (KeyDownEvent)event;
        }
        isCtrlDown = event.isControlKeyDown();
        isAltDown = event.isAltKeyDown();
        isShiftDown  = event.isShiftKeyDown();
    }
    int temp = 0;
    if (kP_Event != null){
        charCode = kP_Event.getUnicodeCharCode();
    } else if (kD_Event != null){
        temp = keyCode = kD_Event.getNativeKeyCode();
    } 
    isFunctionKey = false;
    for (int k : keyCodes){
        if (temp == k) {
            isFunctionKey = true;
            break;
        }
    }
}
项目:Wiab.pro    文件:FocusManager.java   
private void dispatch(KeyEvent<?> event) {
  if (checkStatDialogCondition(event)) {
    StatDialog.show();
  } else {
    Timer timer = null;
    if (Timing.isEnabled()) {
      Timing.enterScope();
      Timing.setScopeValue(ExecutionTree.class, new ExecutionTree());
      timer = Timing.start("Key event dispatch");
    }
    try {
      // Only respond to key events on the body element. Otherwise, the key
      // event was probably targeted to some editable input element, and that
      // should own the events.
      NativeEvent realEvent = event.getNativeEvent();
      Element target = realEvent.getEventTarget().cast();
      if (!"body".equals(target.getTagName().toLowerCase())) {
        return;
      }
      // Test that the event is meaningful (and stop bubbling if it is not).
      SignalEvent signal = SignalEventImpl.create(realEvent.<Event>cast(), true);
      if (signal != null) {
        KeyCombo key = EventWrapper.getKeyCombo(signal);
        if (globalHandler.onKeySignal(key)) {
          event.preventDefault();
        }
      }
    } finally {
      Timing.stop(timer);
      Timing.exitScope();
    }
  }
}
项目:Wiab.pro    文件:FocusManager.java   
private boolean checkStatDialogCondition(KeyEvent<?> event) {
  boolean down = event instanceof KeyDownEvent;
  if (checkStatDialogCondition(statDialogCondition, event.getNativeEvent().getKeyCode(), down)) {
    if (statDialogCondition/2 == statDialogKeyCodeSequence.length-1) {
      statDialogCondition = 0;
      return true;
    }
    statDialogCondition++;
  } else if (statDialogCondition != 0) {
    statDialogCondition = checkStatDialogCondition(0, event.getNativeEvent().getKeyCode(), down) ? 1 : 0;
  }
  return false;
}
项目:opennmszh    文件:Code.java   
/**
 * The Code(KeyEvent event) constructor takes a generic KeyEvent and decides whether
 * it is a KeyPressEvent or KeyDownEvent. Any relevant information about the event
 * is extracted and stored in class variables
 * @param event generic KeyEvent
 */
@SuppressWarnings("unchecked")
public Code(KeyEvent event){
    if (event != null){
        if (event instanceof KeyPressEvent){
            kP_Event = (KeyPressEvent)event;
        } else if (event instanceof KeyDownEvent){
            kD_Event = (KeyDownEvent)event;
        }
        isCtrlDown = event.isControlKeyDown();
        isAltDown = event.isAltKeyDown();
        isShiftDown  = event.isShiftKeyDown();
    }

    if (kP_Event != null){
        charCode = kP_Event.getUnicodeCharCode();
    } else if (kD_Event != null){
        keyCode = kD_Event.getNativeKeyCode();
    } 

    isFunctionKey = false;
    for (int k : keyCodes){
        if (keyCode == k) {
            isFunctionKey = true;
            break;
        }
    }
}
项目:incubator-wave    文件:FocusManager.java   
private void dispatch(KeyEvent<?> event) {
     if (checkStatDialogCondition(event)) {
       StatDialog.show();
     } else {
Timer timer = null;
       if (Timing.isEnabled()) {
         Timing.enterScope();
         Timing.setScopeValue(ExecutionTree.class, new ExecutionTree());
         timer = Timing.start("Key event dispatch");
       }
       try {
         // Only respond to key events on the body element. Otherwise, the key
         // event was probably targeted to some editable input element, and that
         // should own the events.
         NativeEvent realEvent = event.getNativeEvent();
         Element target = realEvent.getEventTarget().cast();
         if (!"body".equals(target.getTagName().toLowerCase())) {
           return;
         }
         // Test that the event is meaningful (and stop bubbling if it is not).
         SignalEvent signal = SignalEventImpl.create(realEvent.<Event>cast(), true);
         if (signal != null) {
           KeyCombo key = EventWrapper.getKeyCombo(signal);
           if (globalHandler.onKeySignal(key)) {
             event.preventDefault();
           }
         }
       } finally {
         Timing.stop(timer);
         Timing.exitScope();
       }
     }
   }
项目:incubator-wave    文件:FocusManager.java   
private boolean checkStatDialogCondition(KeyEvent<?> event) {
  boolean down = event instanceof KeyDownEvent;
  if (checkStatDialogCondition(statDialogCondition, event.getNativeEvent().getKeyCode(), down)) {
    if (statDialogCondition/2 == statDialogKeyCodeSequence.length-1) {
      statDialogCondition = 0;
      return true;
    }
    statDialogCondition++;
  } else if (statDialogCondition != 0) {
    statDialogCondition = checkStatDialogCondition(0, event.getNativeEvent().getKeyCode(), down) ? 1 : 0;
  }
  return false;
}
项目:qafe-platform    文件:ComponentHelper.java   
public static boolean isNonCharKeyPressed(KeyEvent event, char charCode) {
    if (event.isAnyModifierKeyDown()) {
        return true;
    }
    return (charCode == 0);
}