private boolean processKeyMaps(EditorContext editorContext, KeyEvent keyEvent) {
    EditorCell selectedCell = editorContext.getSelectedCell();
    if (selectedCell == null) {
      return false;
    }

    if (keyEvent.getID() != KeyEvent.KEY_PRESSED && keyEvent.getID() != KeyEvent.KEY_TYPED) {
      // Looks like unnecessary check
      return false;
    }

    int keyCode = keyEvent.getKeyCode();
    if (keyCode == KeyEvent.VK_CONTROL
        || keyCode == KeyEvent.VK_ALT
        || keyCode == KeyEvent.VK_SHIFT
        || keyCode == KeyEvent.VK_PAGE_UP
        || keyCode == KeyEvent.VK_PAGE_DOWN) {
      return false;
    }

    Collection<Pair<KeyMapAction, EditorCell>> actionCellPairs =
        myKeymapHandler.getActions(selectedCell, keyEvent, editorContext);
    if (actionCellPairs.size() == 0) {
      return false;
    }
    Pair<KeyMapAction, EditorCell> first = actionCellPairs.iterator().next();
    if (actionCellPairs.size() == 1 && !first.o1.isMenuAlwaysShown()) {
      myKeymapHandler.executeAction(first.o1, first.o2, editorContext);
    } else {
      // show menu
      myKeymapHandler.showActionsMenu(actionCellPairs, editorContext, selectedCell);
    }
    return true;
  }
예제 #2
0
 /* (non-Javadoc)
  * @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent)
  */
 @Override
 public boolean dispatchKeyEvent(final KeyEvent e) {
   // Show Forge menu if Alt key pressed without modifiers and released without pressing any other
   // keys in between
   if (e.getKeyCode() == KeyEvent.VK_ALT) {
     if (e.getID() == KeyEvent.KEY_RELEASED) {
       if (altKeyLastDown) {
         forgeMenu.show(true);
         return true;
       }
     } else if (e.getID() == KeyEvent.KEY_PRESSED && e.getModifiers() == InputEvent.ALT_MASK) {
       altKeyLastDown = true;
     }
   } else {
     altKeyLastDown = false;
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       if (forgeMenu.handleKeyEvent(e)) { // give Forge menu the chance to handle the key event
         return true;
       }
     } else if (e.getID() == KeyEvent.KEY_RELEASED) {
       if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
         forgeMenu.show();
       }
     }
   }
   // Allow the event to be redispatched
   return false;
 }
예제 #3
0
 void dispatch() {
   synchronized (events) {
     if (mousemv != null) {
       mousepos = new Coord(mousemv.getX(), mousemv.getY());
       ui.mousemove(mousemv, mousepos);
       mousemv = null;
     }
     InputEvent e = null;
     while ((e = events.poll()) != null) {
       if (e instanceof MouseEvent) {
         MouseEvent me = (MouseEvent) e;
         if (me.getID() == MouseEvent.MOUSE_PRESSED) {
           ui.mousedown(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
           ui.mouseup(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me instanceof MouseWheelEvent) {
           ui.mousewheel(
               me, new Coord(me.getX(), me.getY()), ((MouseWheelEvent) me).getWheelRotation());
         }
       } else if (e instanceof KeyEvent) {
         KeyEvent ke = (KeyEvent) e;
         if (ke.getID() == KeyEvent.KEY_PRESSED) {
           ui.keydown(ke);
         } else if (ke.getID() == KeyEvent.KEY_RELEASED) {
           ui.keyup(ke);
         } else if (ke.getID() == KeyEvent.KEY_TYPED) {
           ui.type(ke);
         }
       }
       ui.lastevent = System.currentTimeMillis();
     }
   }
 }
예제 #4
0
  public boolean dispatchKeyEvent(KeyEvent e) {
    if (e.getID() == KeyEvent.KEY_PRESSED) {
      pressed.add(e.getKeyCode());
      MouseListener mlis;

      if ((mlis = mListeners.get(e.getKeyCode())) != null) {
        mlis.mouseClicked(null);
      }
      if (buttons.containsKey(e.getKeyCode())) {
        ArrayList<JButton> list = buttons.get(e.getKeyCode());
        if (bid.containsKey(e.getKeyCode())) {
          for (int i = 0; i < list.size(); ++i) {
            int k = isPressed(KeyEvent.VK_SHIFT) ? -1 : 1;
            int a = (bid.get(e.getKeyCode()) + k + list.size()) % list.size();
            bid.put(e.getKeyCode(), a);
            if (list.get(a).isVisible()) {
              list.get(a).doClick();
              break;
            }
          }
        } else {
          for (JButton button : buttons.get(e.getKeyCode())) {
            if (button != null && button.isVisible()) {
              button.doClick();
              break;
            }
          }
        }
      }
    }
    if (e.getID() == KeyEvent.KEY_RELEASED) {
      pressed.remove(e.getKeyCode());
    }
    return false;
  }
  @Override
  public void eventDispatched(AWTEvent event) {
    assert event instanceof KeyEvent
        : "Shall only listen to KeyEvents, so no other events shall come here";
    assert assertEDT(); // REMEMBER THAT THIS IS SINGLE THREADED, so no need for synch.

    // ?: Is this one of our synthetic RELEASED events?
    if (event instanceof Reposted) {
      // -> Yes, so we shalln't process it again.
      return;
    }

    // ?: KEY_TYPED event? (We're only interested in KEY_PRESSED and KEY_RELEASED).
    if (event.getID() == KeyEvent.KEY_TYPED) {
      // -> Yes, TYPED, don't process.
      return;
    }

    final KeyEvent keyEvent = (KeyEvent) event;

    // ?: Is this already consumed?
    // (Note how events are passed on to all AWTEventListeners even though a previous one consumed
    // it)
    if (keyEvent.isConsumed()) {
      return;
    }

    // ?: Is this RELEASED? (the problem we're trying to fix!)
    if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
      // -> Yes, so stick in wait
      /**
       * Really just wait until "immediately", as the point is that the subsequent PRESSED shall
       * already have been posted on the event queue, and shall thus be the direct next event no
       * matter which events are posted afterwards. The code with the ReleasedAction handles if the
       * Timer thread actually fires the action due to lags, by cancelling the action itself upon
       * the PRESSED.
       */
      final Timer timer = new Timer(2, null);
      ReleasedAction action = new ReleasedAction(keyEvent, timer);
      timer.addActionListener(action);
      timer.start();

      _map.put(Integer.valueOf(keyEvent.getKeyCode()), action);

      // Consume the original
      keyEvent.consume();
    } else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
      // Remember that this is single threaded (EDT), so we can't have races.
      ReleasedAction action = _map.remove(Integer.valueOf(keyEvent.getKeyCode()));
      // ?: Do we have a corresponding RELEASED waiting?
      if (action != null) {
        // -> Yes, so dump it
        action.cancel();
      }
      // System.out.println("PRESSED: [" + keyEvent + "]");
    } else {
      throw new AssertionError("All IDs should be covered.");
    }
  }
예제 #6
0
 void notifyKeyEvent(final KeyEvent e) {
   for (KeyListener l : myKeyListeners) {
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       l.keyPressed(e);
     } else if (e.getID() == KeyEvent.KEY_RELEASED) {
       l.keyReleased(e);
     } else if (e.getID() == KeyEvent.KEY_TYPED) {
       l.keyTyped(e);
     }
   }
 }
예제 #7
0
 private void fireKeyEvent(KeyEvent e) {
   for (KeyListener l : mKeyListeners) {
     if (e.getID() == KeyEvent.KEY_PRESSED) {
       l.keyPressed(e);
     } else if (e.getID() == KeyEvent.KEY_RELEASED) {
       l.keyReleased(e);
     } else if (e.getID() == KeyEvent.KEY_TYPED) {
       l.keyTyped(e);
     }
   }
 }
  @Override
  public boolean dispatchKeyEvent(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (e.getID() == KEY_PRESSED) {
      try {
        handleKeyPressed(keyCode);
      } catch (IOException | InterruptedException e1) {
        e1.printStackTrace();
      }
    } else if (e.getID() == KEY_RELEASED) {
      handleKeyReleased(keyCode);
    }

    return true;
  }
예제 #9
0
 /** @param e */
 public void keyEvent(KeyEvent e) {
   int evtID = e.getID();
   if (evtID != KeyEvent.KEY_PRESSED) return;
   switch (e.getKeyCode()) {
     case KeyEvent.VK_BACK_SPACE:
       app.popScene();
       break;
     case KeyEvent.VK_F1:
       this.setClearColor(new MTColor(100, 99, 99, 255));
       break;
     case KeyEvent.VK_F2:
       this.setClearColor(new MTColor(120, 119, 119, 255));
       break;
     case KeyEvent.VK_F3:
       this.setClearColor(new MTColor(130, 129, 129, 255));
       break;
     case KeyEvent.VK_F4:
       this.setClearColor(new MTColor(160, 159, 159, 255));
       break;
     case KeyEvent.VK_F5:
       this.setClearColor(new MTColor(180, 179, 179, 255));
       break;
     case KeyEvent.VK_F6:
       this.setClearColor(new MTColor(100, 100, 102, 255));
       break;
     case KeyEvent.VK_F7:
       this.setClearColor(new MTColor(70, 70, 72, 255));
       break;
     case KeyEvent.VK_F:
       System.out.println("FPS: " + app.frameRate);
       break;
     default:
       break;
   }
 }
예제 #10
0
  public void actionPerformed(@NotNull AnActionEvent event) {
    if (logger.isDebugEnabled()) {
      logger.debug("actionPerformed=" + event);
    }
    if (!VimPlugin.isEnabled()) {
      return;
    }

    if (event.getInputEvent() instanceof KeyEvent) {
      KeyEvent ke = (KeyEvent) event.getInputEvent();
      Editor editor = event.getData(PlatformDataKeys.EDITOR);
      if (editor != null) {
        KeyStroke key = KeyStroke.getKeyStrokeForEvent(ke);
        KeyHandler.getInstance().handleKey(editor, key, event.getDataContext());
      } else {
        if (ExEntryPanel.getInstance().isActive()) {
          KeyEvent e =
              new KeyEvent(
                  ke.getComponent(),
                  ke.getID(),
                  ke.getWhen(),
                  ke.getModifiers(),
                  ke.getKeyCode(),
                  ke.getKeyChar(),
                  ke.getKeyLocation());
          ExEntryPanel.getInstance().processKey(e);
        }
      }
    }
  }
예제 #11
0
    public void processKeyEvent(Component focusedComponent, KeyEvent e) {
      if (e.getID() != KeyEvent.KEY_PRESSED) return;

      int keyCode = e.getKeyCode();

      if (keyCode == KeyEvent.VK_CAPS_LOCK
          || // the keys we want to ignore...
          keyCode == KeyEvent.VK_SHIFT
          || keyCode == KeyEvent.VK_CONTROL
          || keyCode == KeyEvent.VK_META
          || keyCode == KeyEvent.VK_ALT
          || keyCode == KeyEvent.VK_ALT_GRAPH
          || keyCode == KeyEvent.VK_COMPOSE
          || keyCode == KeyEvent.VK_NUM_LOCK
          || keyCode == KeyEvent.VK_SCROLL_LOCK
          || keyCode == KeyEvent.VK_UNDEFINED) return;

      if (currentAction == null) Debug.message("FunctionDialog: currentAction is null...");
      else {
        KeyStroke key = KeyStroke.getKeyStrokeForEvent(e);
        if (isPrintable(key, e)) helpLabel.setText(getHelpText("cannot-redefine"));
        else {
          actions.addActionForKeyStroke(key, currentAction);
          handleFuncListSelect();
        }
      }
      e.consume();
      removeKeyListener();
    }
    /**
     * There are two special cases where we need to override the default behavior when we begin cell
     * editing. For some reason, when you use the keyboard to enter a cell (tab, enter, arrow keys,
     * etc), the first character that you type after entering the field is NOT passed through the
     * KeyListener mechanism where we have the special handling in the DataTypes. Instead, it is
     * passed through the KeyMap and Action mechanism, and the default Action on the JTextField is
     * to add the character to the end of the existing text, or if it is delete to delete the last
     * character of the existing text. In most cases, this is ok, but there are three special cases
     * of which we only handle two here: - If the data field currently contains "<null>" and the
     * user types a character, we want that character to replace the string "<null>", which
     * represents the null value. In this case we process the event normally, which usually adds the
     * char to the end of the string, then remove the char afterwards. We take this approach rather
     * than just immediately replacing the "<null>" with the char because there are some chars that
     * should not be put into the editable text, such as control-characters. - If the data field
     * contains "<null>" and the user types a delete, we do not want to delete the last character
     * from the string "<null>" since that string represents the null value. In this case we simply
     * ignore the user input. - Whether or not the field initially contains null, we do not run the
     * input validation function for the DataType on the input character. This means that the user
     * can type an illegal character into the field. For example, after entering an Integer field by
     * typing a tab, the user can enter a letter (e.g. "a") into that field. The normal keyListener
     * processing prevents that, but we cannot call it from this point. (More accurately, I cannot
     * figure out how to do it easilly.) Thus the user may enter one character of invalid data into
     * the field. This is not too serious a problem, however, because the normal validation is still
     * done when the user leaves the field and it SQuirreL tries to convert the text into an object
     * of the correct type, so errors of this nature will still be caught. They just won't be
     * prevented.
     */
    public void processKeyEvent(KeyEvent e) {

      // handle special case of delete with <null> contents
      if (e.getKeyChar() == '\b'
          && getEditorComponent() != null
          && ((RestorableJTextField) getEditorComponent()).getText().equals("<null>")) {
        // ignore the user input
        return;
      }

      // generally for KEY_TYPED this means add the typed char to the end of the text,
      // but there are some things (e.g. control chars) that are ignored, so let the
      // normal processing do its thing
      super.processKeyEvent(e);

      // now check to see if the original contents were <null>
      // and we have actually added the input char to the end of it
      if (getEditorComponent() != null) {
        if (e.getID() == KeyEvent.KEY_TYPED
            && ((RestorableJTextField) getEditorComponent()).getText().length() == 7) {
          // check that we did not just add a char to a <null>
          if (((RestorableJTextField) getEditorComponent())
              .getText()
              .equals("<null>" + e.getKeyChar())) {
            // replace the null with just the char
            ((RestorableJTextField) getEditorComponent()).updateText("" + e.getKeyChar());
          }
        }
      }
    }
예제 #13
0
 // #{GxwCbkHost_
 public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) {
   boolean rv = true;
   int id = e.getID(), val = e.getKeyCode();
   boolean isAltF4 = false;
   if (e.isAltDown() && val == IptKey_.F4.Val()) {
     isAltF4 = true;
   }
   if (id == KeyEvent.KEY_TYPED) {
     IptEvtDataKeyHeld keyHeldData = IptEvtDataKeyHeld.char_(e.getKeyChar());
     rv = host.KeyHeldCbk(keyHeldData);
     if (keyHeldData.Handled()) rv = false;
   } else {
     if (e.isShiftDown()) val |= IptKey_.Shift.Val();
     if (e.isControlDown()) val |= IptKey_.Ctrl.Val();
     if (e.isAltDown()) val |= IptKey_.Alt.Val();
     IptEvtDataKey keyData = IptEvtDataKey.int_(val);
     //			Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id);
     if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData);
     else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData);
     if (keyData.Handled()) rv = false; // was false
   }
   if (isAltF4) {
     e.consume();
   }
   if (e.getKeyCode() == KeyEvent.VK_ALT)
     e.consume(); // force consume of alt-keys; occurs when alt-f4ing out of video app (though
   // not audio app)
   return rv;
 }
예제 #14
0
  /**
   * The key event major processor. The code is adopted from the code provided by the Java
   * documentation for key event processing.
   *
   * <p><em>We have to jump through some hoops to avoid trying to print non-printing characters such
   * as Shift. (Not only do they not print, but if you put them in a String, the characters
   * afterward won't show up in the text area.)</em>
   *
   * <p>There may be unneeded code here. An earlier comment stated: <em>needs to add conversion
   * table from code to </em><code>String</code>. The code for converting a single character to
   * <code>String</code> is included here.
   */
  protected void displayInfo(KeyEvent e, String s) {
    String keyString = "";

    // You should only rely on the key char if the event
    // is a key typed event.
    int id = e.getID();
    if (id == KeyEvent.KEY_TYPED) {
      // regular letter has been pressed and released
      char c = e.getKeyChar();
      keyString = "" + c;

      // process four arrow keys when pressed
    } else if (id == KeyEvent.KEY_PRESSED) {
      // check if pressed is one of the arrows
      int keyCode = e.getKeyCode();
      if (keyCode == 37) keyString = "left";
      else if (keyCode == 38) keyString = "up";
      else if (keyCode == 39) keyString = "right";
      else if (keyCode == 40) keyString = "down";
      else ; // ignore other keys pressed

      // record the KEY_RELEASED event
    } else {
      keyString = "released";
    }

    //////////////////////////////////////////////////////////////////////////
    // here is the actual callback                                          //
    if (!(keyString.length() == 0
        || // ignore key pressed except arrows //
        keyString.equals("released"))) // ignore key released              //
    keyEventCallback(keyString); //
    //////////////////////////////////////////////////////////////////////////
  }
예제 #15
0
 protected void processKeyEvent(final KeyEvent e) {
   int id = e.getID();
   switch (id) {
     case KeyEvent.KEY_TYPED:
       KeyEventCZ loKey = new KeyEventCZ(e.getKeyChar());
       moTipo.getTecla(super.getText(), loKey);
       e.setKeyChar(loKey.getKeyChar());
       break;
     case KeyEvent.KEY_PRESSED:
       if (e.getKeyCode() == e.VK_ENTER) {
         e.setKeyCode(0);
         transferFocus();
       }
       if (e.getKeyCode() == e.VK_ESCAPE) {
         e.setKeyCode(0);
         moTipo.restaurarTexto();
         super.setText(moTipo.getText());
       }
       break;
     case KeyEvent.KEY_RELEASED:
       break;
     default:
   }
   super.processKeyEvent(e);
 }
예제 #16
0
  /**
   * Return a String representation of the keyboard event for debugging purpose.
   *
   * @param evt the keyboard event
   * @return a String representation for this keyboard event
   * @since jEdit 4.3pre15
   */
  public static String toString(KeyEvent evt) {
    String id;
    switch (evt.getID()) {
      case KeyEvent.KEY_PRESSED:
        id = "KEY_PRESSED";
        break;
      case KeyEvent.KEY_RELEASED:
        id = "KEY_RELEASED";
        break;
      case KeyEvent.KEY_TYPED:
        id = "KEY_TYPED";
        break;
      default:
        id = "unknown type";
        break;
    }

    StringBuilder b = new StringBuilder(50);

    b.append(id);
    b.append(",keyCode=0x").append(Integer.toString(evt.getKeyCode(), 16));
    b.append(",keyChar=0x").append(Integer.toString(evt.getKeyChar(), 16));
    b.append(",modifiers=0x").append(Integer.toString(evt.getModifiers(), 16));

    b.append(",consumed=");
    b.append(evt.isConsumed() ? '1' : '0');

    return b.toString();
  } // }}}
  public static boolean isTooltipRequest(KeyEvent keyEvent) {
    if (ourTooltipKeysProperty == null) {
      ourTooltipKeysProperty = Registry.get("ide.forcedShowTooltip");
      ourTooltipKeysProperty.addListener(
          new RegistryValueListener.Adapter() {
            @Override
            public void afterValueChanged(RegistryValue value) {
              updateTooltipRequestKey(value);
            }
          },
          Disposer.get("ui"));

      updateTooltipRequestKey(ourTooltipKeysProperty);
    }

    if (keyEvent.getID() != KeyEvent.KEY_PRESSED) return false;

    for (Integer each : ourTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) == 0) return false;
    }

    for (Integer each : ourOtherTooltipKeys) {
      if ((keyEvent.getModifiers() & each.intValue()) > 0) return false;
    }

    final int code = keyEvent.getKeyCode();

    return code == KeyEvent.VK_META
        || code == KeyEvent.VK_CONTROL
        || code == KeyEvent.VK_SHIFT
        || code == KeyEvent.VK_ALT;
  }
예제 #18
0
 @Override
 protected void processKeyEvent(KeyEvent e) {
   // TODO: Convert into Actions and put into InputMap/ActionMap?
   final int hexColumns = model.getNumberOfHexColumns();
   final long lastOffset = model.getSize() - 1;
   final boolean extend = e.isShiftDown();
   if (e.getID() == KeyEvent.KEY_PRESSED) {
     switch (e.getKeyCode()) {
       case KeyEvent.VK_LEFT:
         long offs = leadSelectionIndex > 0 ? leadSelectionIndex - 1 : 0;
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_RIGHT:
         offs = Math.min(leadSelectionIndex + 1, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_UP:
         offs = Math.max(leadSelectionIndex - hexColumns, 0);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_DOWN:
         offs = Math.min(leadSelectionIndex + hexColumns, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_PAGE_DOWN:
         int visibleRowCount = getVisibleRect().height / getRowHeight();
         offs = Math.min(leadSelectionIndex + visibleRowCount * hexColumns, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         break;
       case KeyEvent.VK_PAGE_UP:
         visibleRowCount = getVisibleRect().height / getRowHeight();
         offs = Math.max(leadSelectionIndex - visibleRowCount * hexColumns, 0);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_HOME:
         offs = (leadSelectionIndex / hexColumns) * hexColumns;
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_END:
         offs = (leadSelectionIndex / hexColumns) * hexColumns + hexColumns - 1;
         offs = Math.min(offs, lastOffset);
         changeSelectionByOffset(offs, extend);
         e.consume();
         return;
       case KeyEvent.VK_BACK_SPACE:
         // System.out.println();
         // Profiler.print();
         // System.out.println(Profiler.getTime());
         return;
     }
   }
   super.processKeyEvent(e);
 }
 @Override
 public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
   assert assertEDT();
   // ?: Are we already cancelled?
   // (Judging by Timer and TimerQueue code, we can theoretically be raced to be posted onto EDT
   // by TimerQueue,
   // due to some lag, unfair scheduling)
   if (_timer == null) {
     // -> Yes, so don't post the new RELEASED event.
     return;
   }
   // Stop Timer and clean.
   cancel();
   // Creating new KeyEvent (we've consumed the original).
   KeyEvent newEvent =
       new RepostedKeyEvent(
           (Component) _originalKeyEvent.getSource(),
           _originalKeyEvent.getID(),
           _originalKeyEvent.getWhen(),
           _originalKeyEvent.getModifiers(),
           _originalKeyEvent.getKeyCode(),
           _originalKeyEvent.getKeyChar(),
           _originalKeyEvent.getKeyLocation());
   // Posting to EventQueue.
   Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(newEvent);
   // System.out.println("Posted synthetic RELEASED [" + newEvent + "].");
 }
예제 #20
0
  /** Handles the event when the key is pressed */
  public void processKeyEvent(KeyEvent e) {
    int keyCode = e.getKeyCode();

    if (e.getID() == KeyEvent.KEY_PRESSED) {
      if (keyCode == KeyEvent.VK_Z) lockZoom();
      else if (keyCode == KeyEvent.VK_T) fixElTimePointer(currTime);
    } else super.processKeyEvent(e);
  }
  private boolean inProcessedState() {
    KeyEvent e = myContext.getInputEvent();

    // ignore typed events which come after processed pressed event
    if (KeyEvent.KEY_TYPED == e.getID() && isPressedWasProcessed()) {
      return true;
    }
    if (KeyEvent.KEY_RELEASED == e.getID()
        && KeyEvent.VK_ALT == e.getKeyCode()
        && isPressedWasProcessed()) {
      // see IDEADEV-8615
      return true;
    }
    setState(KeyState.STATE_INIT);
    setPressedWasProcessed(false);
    return inInitState();
  }
예제 #22
0
 @Override
 protected void processKeyEvent(KeyEvent e) {
   if (e.getID() == KeyEvent.KEY_TYPED) {
     if (!Character.isDigit(e.getKeyChar()) && !(!positiveOnly && e.getKeyChar() == '-')) {
       e.consume();
     }
   }
   super.processKeyEvent(e);
 }
예제 #23
0
    public void processKeyEvent(KeyEvent evt) {
      evt = KeyEventWorkaround.processKeyEvent(evt);
      if (evt == null) return;

      switch (evt.getID()) {
        case KeyEvent.KEY_TYPED:
          char ch = evt.getKeyChar();
          if (!nonDigit && Character.isDigit(ch)) {
            super.processKeyEvent(evt);
            repeat = true;
            repeatCount = Integer.parseInt(action.getText());
          } else {
            nonDigit = true;
            if (repeat) {
              passToView(evt);
            } else super.processKeyEvent(evt);
          }
          break;
        case KeyEvent.KEY_PRESSED:
          int keyCode = evt.getKeyCode();
          if (evt.isActionKey()
              || evt.isControlDown()
              || evt.isAltDown()
              || evt.isMetaDown()
              || keyCode == KeyEvent.VK_BACK_SPACE
              || keyCode == KeyEvent.VK_DELETE
              || keyCode == KeyEvent.VK_ENTER
              || keyCode == KeyEvent.VK_TAB
              || keyCode == KeyEvent.VK_ESCAPE) {
            nonDigit = true;
            if (repeat) {
              passToView(evt);
              break;
            } else if (keyCode == KeyEvent.VK_TAB) {
              complete(true);
              evt.consume();
            } else if (keyCode == KeyEvent.VK_ESCAPE) {
              evt.consume();
              if (popup != null) {
                popup.dispose();
                popup = null;
                action.requestFocus();
              } else {
                if (temp) view.removeToolBar(ActionBar.this);
                view.getEditPane().focusOnTextArea();
              }
              break;
            } else if ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN)
                && popup != null) {
              popup.list.processKeyEvent(evt);
              break;
            }
          }
          super.processKeyEvent(evt);
          break;
      }
    }
예제 #24
0
 public void handleKeyEvent(KeyEvent e) {
   final int id = e.getID();
   if (id == KeyEvent.KEY_PRESSED) {
     myKeyListener.keyPressed(e);
   } else if (id == KeyEvent.KEY_RELEASED) {
     /* keyReleased(e); */
   } else if (id == KeyEvent.KEY_TYPED) {
     myKeyListener.keyTyped(e);
   }
 }
예제 #25
0
 public void keyEvent(KeyEvent e) {
   int evtID = e.getID();
   if (evtID != KeyEvent.KEY_PRESSED) return;
   switch (e.getKeyCode()) {
     case KeyEvent.VK_F:
       System.out.println("FPS: " + pa.frameRate);
       break;
     default:
       break;
   }
 }
예제 #26
0
 @Override
 public boolean dispatchKeyEvent(KeyEvent e) {
   if (isDraggingNow()
       && e.getKeyCode() == KeyEvent.VK_ESCAPE
       && e.getID() == KeyEvent.KEY_PRESSED) {
     myDragCancelled = true;
     finishDragging();
     return true;
   }
   return false;
 }
예제 #27
0
 public void eventDispatched(AWTEvent event) {
   KeyEvent ke = (KeyEvent) event;
   if (ke.getID() == KeyEvent.KEY_TYPED) {
     if (ke.getKeyChar() == KeyEvent.VK_ESCAPE) {
       disableScanning();
     } else {
       // JOptionPane.showMessageDialog(null,ke.getKeyText(ke.getKeyChar()),"JAVA
       // PLAPHOONS",JOptionPane.INFORMATION_MESSAGE);
     }
   }
 }
예제 #28
0
    public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {
      KeyPressedEvent obj = (KeyPressedEvent) object;
      java.awt.event.KeyEvent src = obj.getSourceEvent();

      serializer.serialize(buffer, src.getKeyChar());
      serializer.serialize(buffer, src.getKeyCode());
      serializer.serialize(buffer, src.getKeyLocation());
      serializer.serialize(buffer, src.getID());
      serializer.serialize(buffer, src.getModifiersEx());
      serializer.serialize(buffer, src.getWhen());
    }
예제 #29
0
  static boolean processKeyEventOnComponent(final Component target, final KeyEvent event) {
    if (target instanceof JComponent) {
      final boolean pressed = (event.getID() == KeyEvent.KEY_PRESSED);
      final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(event);
      if (((JComponent) target)
          .processKeyBinding(keyStroke, event, JComponent.WHEN_IN_FOCUSED_WINDOW, pressed)) {
        return true;
      }
    }

    return false;
  }
예제 #30
0
 protected void processKeyEvent(KeyEvent e) {
   if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     EventListener[] el = super.getListeners(KeyListener.class);
     if (e.getID() != KeyEvent.KEY_RELEASED) return;
     for (int i = 0; i < el.length; i++) {
       KeyListener kl = (KeyListener) el[i];
       kl.keyReleased(e);
     }
     return;
   }
   super.processKeyEvent(e);
 }