@Override
  public void onKeyDown(KeyDownEvent event) {
    switch (event.getNativeEvent().getKeyCode()) {
      case 38: /*up*/
      case 87: /*W*/
        this.moveForward = true;
        break;

      case 37: /*left*/
      case 65: /*A*/
        this.moveLeft = true;
        break;

      case 40: /*down*/
      case 83: /*S*/
        this.moveBackward = true;
        break;

      case 39: /*right*/
      case 68: /*D*/
        this.moveRight = true;
        break;

      case 82: /*R*/
        this.moveUp = true;
        break;
      case 70: /*F*/
        this.moveDown = true;
        break;

      case 81: /*Q*/
        this.freeze = !this.freeze;
        break;
    }
  }
Esempio n. 2
0
 @Override
 public void onKeyDown(KeyDownEvent event) {
   if (shortcutHandler != null) {
     shortcutHandler.handleKeyboardEvent(Event.as(event.getNativeEvent()));
     return;
   }
 }
Esempio n. 3
0
 @Override
 public void onKeyDown(KeyDownEvent event) {
   ignoreNextKeyPress = true;
   Event nativeEvent = (Event) event.getNativeEvent();
   if (!nativeEvent.isCancelled()) {
     handleRepeatableKey(nativeEvent);
   }
   cancelNextKeyPress = nativeEvent.isCancelled();
 }
Esempio n. 4
0
 /**
  * The onKeyDown method handles all keys that are held down, before KeyUp and KeyPress events are
  * triggered.
  */
 @Override
 public void onKeyDown(KeyDownEvent event) {
   code = new Code(event);
   if (!code.isControlKey()) {
     if (code.isFunctionKey() || code.isCtrlDown() || code.isAltDown()) {
       processCode(code);
       event.getNativeEvent().stopPropagation();
       event.getNativeEvent().preventDefault();
     }
   }
 }
Esempio n. 5
0
  private void handleKeyDown(KeyDownEvent event) {
    int modifiers = KeyboardShortcut.getModifierValue(event.getNativeEvent());
    switch (event.getNativeKeyCode()) {
      case KeyCodes.KEY_UP:
      case KeyCodes.KEY_DOWN:
        break;
      default:
        return;
    }

    if (!allowMultiSelect_) modifiers = KeyboardShortcut.NONE;

    event.preventDefault();
    event.stopPropagation();

    switch (modifiers) {
      case 0:
      case KeyboardShortcut.SHIFT:
        break;
      default:
        return;
    }

    sortSelectedRows();
    int min = table_.getRows().getLength();
    int max = -1;
    if (selectedRows_.size() > 0) {
      min = selectedRows_.get(0).getRowIndex();
      max = selectedRows_.get(selectedRows_.size() - 1).getRowIndex();
    }

    switch (event.getNativeKeyCode()) {
      case KeyCodes.KEY_UP:
        {
          Integer row = findNextValueRow(min, true);
          if (row != null) {
            if (modifiers != KeyboardShortcut.SHIFT) clearSelection();
            setSelectedPhysical(row, 1, true);
            ensureRowVisible(row);
          }
          break;
        }
      case KeyCodes.KEY_DOWN:
        {
          Integer row = findNextValueRow(max, false);
          if (row != null) {
            if (modifiers != KeyboardShortcut.SHIFT) clearSelection();
            setSelectedPhysical(row, 1, true);
            ensureRowVisible(row);
          }
          break;
        }
    }
  }
Esempio n. 6
0
    public void onKeyDown(KeyDownEvent event) {
      int keyCode = event.getNativeKeyCode();

      for (KeyDownPreviewHandler handler : keyDownPreviewHandlers_) {
        if (handler.previewKeyDown(event.getNativeEvent())) {
          event.preventDefault();
          event.stopPropagation();
          return;
        }
      }

      if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) event.preventDefault();

      int modifiers = KeyboardShortcut.getModifierValue(event.getNativeEvent());

      if (event.isUpArrow() && modifiers == 0) {
        if ((input_.getCurrentLineNum() == 0) || input_.isCursorAtEnd()) {
          event.preventDefault();
          event.stopPropagation();

          navigateHistory(-1);
        }
      } else if (event.isDownArrow() && modifiers == 0) {
        if ((input_.getCurrentLineNum() == input_.getCurrentLineCount() - 1)
            || input_.isCursorAtEnd()) {
          event.preventDefault();
          event.stopPropagation();

          navigateHistory(1);
        }
      } else if (keyCode == KeyCodes.KEY_ENTER && modifiers == 0) {
        event.preventDefault();
        event.stopPropagation();

        restoreFocus_ = true;
        processCommandEntry();
      } else if (keyCode == KeyCodes.KEY_ESCAPE && modifiers == 0) {
        event.preventDefault();

        if (input_.getText().length() == 0) {
          // view_.isPromptEmpty() is to check for cases where the
          // server is prompting but not at the top level. Escape
          // needs to send null in those cases.
          // For example, try "scan()" function
          if (view_.isPromptEmpty()) {
            // interrupt server
            server_.interrupt(
                new VoidServerRequestCallback() {
                  @Override
                  public void onError(ServerError error) {
                    super.onError(error);
                    globalDisplay_.showErrorMessage(
                        "Error Interrupting Server", error.getUserMessage());
                  }
                });
          } else {
            // if the input is already empty then send a console reset
            // which will jump us back to the main prompt
            eventBus_.fireEvent(new ConsoleInputEvent(null));
          }
        }

        input_.clear();
      } else {
        int mod = KeyboardShortcut.getModifierValue(event.getNativeEvent());
        if (mod == KeyboardShortcut.CTRL) {
          switch (keyCode) {
            case 'L':
              Shell.this.onConsoleClear();
              event.preventDefault();
              break;
          }
        } else if (mod == KeyboardShortcut.ALT) {
          switch (keyCode) {
            case 189: // hyphen
              event.preventDefault();
              event.stopPropagation();
              input_.replaceSelection(" <- ", true);
              break;
          }
        } else if ((BrowseCap.hasMetaKey()
                && (mod == (KeyboardShortcut.META + KeyboardShortcut.SHIFT)))
            || (!BrowseCap.hasMetaKey()
                && (mod == (KeyboardShortcut.CTRL + KeyboardShortcut.SHIFT)))) {
          switch (keyCode) {
            case KeyCodes.KEY_M:
              event.preventDefault();
              event.stopPropagation();
              input_.replaceSelection(" %>% ", true);
              break;
          }
        }
      }
    }
 public void onKeyDown(KeyDownEvent event) {
   int keycode = event.getNativeEvent().getKeyCode();
   if (keycode == KeyCodes.KEY_ESCAPE && mouseMoveStarted) {
     cancelMouseMove();
   }
 }