public static void notifyInputKey(
      final boolean isBackspace, final KeyEvent event, final char inputChar) {
    if (currentTabBlock != null) {
      if (L.isInWorkshop) {
        System.out.println("---------notifyInputKey char : " + inputChar);
      }
      if (isBackspace) {
      } else if (inputChar == '\t' || event.isActionKey()) {
        if (L.isInWorkshop) {
          System.out.println(
              "-----isActionKey : " + event.isActionKey() + ", isTab : " + (inputChar == '\t'));
        }
        return;
      }
      final int keyCode = event.getKeyCode();
      if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT) {
        return;
      }

      final boolean snapIsFocusFull = isFocusFullParameter;
      if (snapIsFocusFull) {
        isFocusFullParameter = false;
        try {
          final int removeLen = currFocusHighlightEndIdx - currFocusHighlightStartIdx;
          scriptPanel
              .getDocument()
              .remove(currFocusHighlightStartIdx, removeLen - (isBackspace ? 1 : 0));
          inputShiftOffset -= removeLen;
          currFocusHighlightEndIdx = currFocusHighlightStartIdx;
          currentTabBlock.parameterEndOffsetIdx[parameterIdx] = 0;
        } catch (final BadLocationException e) {
          ExceptionReporter.printStackTrace(e);
        }
      }
      if (isBackspace) {
        if (snapIsFocusFull == false) {
          currentTabBlock.parameterEndOffsetIdx[parameterIdx]--;
          currFocusHighlightEndIdx--;
          inputShiftOffset--;
        }
      } else {
        currentTabBlock.parameterEndOffsetIdx[parameterIdx]++;
        currFocusHighlightEndIdx++;
        inputShiftOffset++;
      }
      SwingUtilities.invokeLater(refreshLightParameter);
    }
  }
Exemple #2
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;
      }
    }
  /**
   * Handle a key pressed event. This will look up the binding for the key stroke and execute it.
   */
  @Override
  @SuppressWarnings("unchecked")
  public void keyPressed(KeyEvent evt) {
    int keyCode = evt.getKeyCode();
    int modifiers = evt.getModifiers();

    if (keyCode == KeyEvent.VK_CONTROL
        || keyCode == KeyEvent.VK_SHIFT
        || keyCode == KeyEvent.VK_ALT
        || keyCode == KeyEvent.VK_META) return;

    if ((modifiers & InputEvent.SHIFT_MASK) != 0
        || (modifiers & InputEvent.CTRL_MASK) != 0
        || evt.isActionKey()
        || keyCode == KeyEvent.VK_BACK_SPACE
        || keyCode == KeyEvent.VK_DELETE
        || keyCode == KeyEvent.VK_ENTER
        || keyCode == KeyEvent.VK_TAB
        || keyCode == KeyEvent.VK_ESCAPE) {

      if (grabAction != null) {
        handleGrabAction(evt);
        return;
      }

      KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
      Object o = currentBindings.get(keyStroke);
      if (o == null) {
        // Don't beep if the user presses some
        // key we don't know about unless a
        // prefix is active. Otherwise it will
        // beep when caps lock is pressed, etc.
        if (currentBindings != bindings) {
          Toolkit.getDefaultToolkit().beep();
          // F10 should be passed on, but C+e F10
          // shouldn't
          repeatCount = 0;
          repeat = false;
          evt.consume();
        }
        currentBindings = bindings;
        return;
      } else if (o instanceof ActionListener) {
        currentBindings = bindings;

        executeAction(((ActionListener) o), evt.getSource(), null);

        evt.consume();
        return;
      } else if (o instanceof Hashtable) {
        currentBindings = (Hashtable) o;
        evt.consume();
        return;
      }
    }
  }
Exemple #4
0
 public void keyTyped(java.awt.event.KeyEvent e) {
   if (e.getKeyChar() != java.awt.event.KeyEvent.CHAR_UNDEFINED
       && !e.isActionKey()
       && (e.getModifiers() & getToolkit().getMenuShortcutKeyMask()) == 0) {
     org.nlogo.window.ButtonWidget button = findActionButton(e.getKeyChar());
     if (button != null) {
       button.keyTriggered();
     }
   }
 }
Exemple #5
0
  public void keyTyped(KeyEvent e) {

    if (e.isActionKey()) {
      E.info("action key " + KeyEvent.getKeyText(keyCode));

    } else {
      char c = e.getKeyChar();
      insertCharacter(c);
    }
  }
  private void displayInfo(KeyEvent e, String keyStatus) {
    // Method copied from http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html

    // You should only rely on the key char if the event
    // is a key typed event.
    int id = e.getID();
    String keyString;
    if (id == KeyEvent.KEY_TYPED) {
      char c = e.getKeyChar();
      keyString = "key character = '" + c + "'";
    } else {
      int keyCode = e.getKeyCode();
      keyString = "key code = " + keyCode + " (" + KeyEvent.getKeyText(keyCode) + ")";
    }

    int modifiersEx = e.getModifiersEx();
    String modString = "extended modifiers = " + modifiersEx;
    String tmpString = KeyEvent.getModifiersExText(modifiersEx);
    if (tmpString.length() > 0) {
      modString += " (" + tmpString + ")";
    } else {
      modString += " (no extended modifiers)";
    }

    String actionString = "action key? ";
    if (e.isActionKey()) {
      actionString += "YES";
    } else {
      actionString += "NO";
    }

    String locationString = "key location: ";
    int location = e.getKeyLocation();
    if (location == KeyEvent.KEY_LOCATION_STANDARD) {
      locationString += "standard";
    } else if (location == KeyEvent.KEY_LOCATION_LEFT) {
      locationString += "left";
    } else if (location == KeyEvent.KEY_LOCATION_RIGHT) {
      locationString += "right";
    } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) {
      locationString += "numpad";
    } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN)
      locationString += "unknown";
    }

    // Added:
    System.out.println("Keypress: " + keyString);
  }
Exemple #7
0
    @Override
    public void keyPressed(KeyEvent keyEvent) {
      // don't popup on action keys (cursor movements, etc...)
      if (keyEvent.isActionKey()) {
        return;
      }

      // don't popup if the combobox isn't visible anyway
      if (comboBox.isDisplayable() && !comboBox.isPopupVisible()) {
        int keyCode = keyEvent.getKeyCode();
        // don't popup when the user hits shift,ctrl or alt
        if (keyCode == KeyEvent.VK_SHIFT
            || keyCode == KeyEvent.VK_CONTROL
            || keyCode == KeyEvent.VK_ALT) return;
        // don't popup when the user hits escape (see issue #311)
        if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_ESCAPE) return;
        comboBox.setPopupVisible(true);
      }
    }
    private boolean isPrintable(KeyStroke key, KeyEvent e) {
      // all control and alt keys are non-printable
      int modifiers = key.getModifiers();
      if (modifiers != 0 && modifiers != Event.SHIFT_MASK) return false;

      // action keys are non-printable
      if (e.isActionKey()) return false;

      // some action keys that the above function not recognises
      int keyCode = e.getKeyCode();
      if (keyCode == KeyEvent.VK_BACK_SPACE
          || keyCode == KeyEvent.VK_DELETE
          || keyCode == KeyEvent.VK_ENTER
          || keyCode == KeyEvent.VK_TAB
          || keyCode == KeyEvent.VK_ESCAPE) return false;

      // otherwise it's printable
      return true;
    }
  @Override
  public void keyPressed(KeyEvent arg0) {
    if (!arg0.isActionKey()) {

      char c = arg0.getKeyChar();

      if (c == ' ' || c == '\n') {
        uncommitedText += c;
        System.out.println("you typed the word: \"" + uncommitedText + "\"");

        /*
         * Code for communicating with PDStore here
         * 1. Create PDWord instance?
         * 2. Commit to PDStore?
         */
        PDWord word = new PDWord(store);
        word.addText(uncommitedText);
        PDOperation op = new PDOperation(store);
        op.setCommand(editor.INSERT);
        Date date = new Date();
        op.setTimeStamp(date.getTime());
        op.setUser(TextEditor.userName);
        PDInsert insert = new PDInsert(store);
        insert.setWord(word);
        insert.setAfter(word);
        op.setSuperParameter(insert);

        history.addOperation(op);

        store.commit();

        // this.repaint();

        uncommitedText = "";
      } else if (c == '\u0008') { // backspace character
        int i = uncommitedText.length();
        uncommitedText = uncommitedText.substring(0, i - 1);
      } else {
        uncommitedText += c;
      }
    }
  }
  /* (non-Javadoc)
   * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
   */
  public void keyPressed(KeyEvent evt) {
    // System.out.println(evt);
    StringBuffer str = new StringBuffer();

    str.append(getModifiers(evt));
    str.append("|");

    if (evt.isActionKey()) {
      str.append(KeyEvent.getKeyText(evt.getKeyCode()));
    } else {
      char c = evt.getKeyChar();

      if (!Character.isISOControl(c)) {
        str.append(Character.toString(c));
      } else {
        int code = evt.getKeyCode();
        str.append(KeyEvent.getKeyText(code));
      }
    }

    evt.consume();
    setText(str.toString());
  }
Exemple #11
0
  private void onPressed(KeyEvent e) {
    if (busChoices != null && busChoices.size() > 0) {
      int keyCode = e.getKeyCode();
      if (e.isActionKey() && (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN)) {
        int maxIndex = busChoices.size() - 1;
        int nowIndex = this.busChoiceIndex;

        if (keyCode == KeyEvent.VK_UP) {
          nowIndex--;
        } else if (keyCode == KeyEvent.VK_DOWN) {
          nowIndex++;
        }

        if (nowIndex > maxIndex) {
          nowIndex = 0;
        } else if (nowIndex < 0) {
          nowIndex = maxIndex;
        }
        this.busChoiceIndex = nowIndex;
        repaint();
      }
    }
  }
Exemple #12
0
 public void keyPressed(KeyEvent e) {
   // TODO Auto-generated method stub
   keyCode.setText("keyCode:" + e.getKeyCode());
   keyText.setText("keyText:" + e.getKeyText(e.getKeyCode()));
   actionKey.setText("actionKey:" + e.isActionKey());
 }
  /**
   * Handle a key pressed event. This will look up the binding for the key stroke and execute it.
   */
  public void keyPressed(KeyEvent evt) {
    int keyCode = evt.getKeyCode();
    int modifiers = evt.getModifiers();

    // moved this earlier so it doesn't get random meta clicks
    if (keyCode == KeyEvent.VK_CONTROL
        || keyCode == KeyEvent.VK_SHIFT
        || keyCode == KeyEvent.VK_ALT
        || keyCode == KeyEvent.VK_META) {
      return;
    }

    // don't get command-s or other menu key equivs on mac
    // unless it's something that's specifically bound (cmd-left or right)
    // if ((modifiers & KeyEvent.META_MASK) != 0) return;
    if ((modifiers & KeyEvent.META_MASK) != 0) {
      KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
      if (currentBindings.get(keyStroke) == null) {
        return;
      }
    }

    /*
    char keyChar = evt.getKeyChar();
    System.out.println("code=" + keyCode + " char=" + keyChar +
                       " charint=" + ((int)keyChar));
    System.out.println("other codes " + KeyEvent.VK_ALT + " " +
                       KeyEvent.VK_META);
    */

    if ((modifiers & ~KeyEvent.SHIFT_MASK) != 0
        || evt.isActionKey()
        || keyCode == KeyEvent.VK_BACK_SPACE
        || keyCode == KeyEvent.VK_DELETE
        || keyCode == KeyEvent.VK_ENTER
        || keyCode == KeyEvent.VK_TAB
        || keyCode == KeyEvent.VK_ESCAPE) {
      if (grabAction != null) {
        handleGrabAction(evt);
        return;
      }

      KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers);
      Object o = currentBindings.get(keyStroke);
      if (o == null) {
        // Don't beep if the user presses some
        // key we don't know about unless a
        // prefix is active. Otherwise it will
        // beep when caps lock is pressed, etc.
        if (currentBindings != bindings) {
          Toolkit.getDefaultToolkit().beep();
          // F10 should be passed on, but C+e F10
          // shouldn't
          repeatCount = 0;
          repeat = false;
          evt.consume();
        }
        currentBindings = bindings;
        return;
      } else if (o instanceof ActionListener) {
        currentBindings = bindings;

        executeAction(((ActionListener) o), evt.getSource(), null);

        evt.consume();
        return;
      } else if (o instanceof Hashtable) {
        currentBindings = (Hashtable) o;
        evt.consume();
        return;
      }
    }
  }
  public void keyTyped(KeyEvent e) {
    if (debug) {
      System.out.println(
          "--- RecordingModule: key typed = "
              + e
              + "\n  > Key char->int = "
              + (int) e.getKeyChar());
      System.out.println(" -- isActionKey() = " + e.isActionKey());
      System.out.println(" -- isISOControl() = " + Character.isISOControl(e.getKeyChar()));
      System.out.println(" -- isWhitespace() = " + Character.isWhitespace(e.getKeyChar()));
    }

    if (isKeyReserved(e)) {
      return;
    }

    if (enabled && !readOnly && lastKeyPressEvent != null) {

      if (enableKeyboard) {
        boolean replace = false;
        String text = "";
        if (isControl(e)) {
          if (lastKeyPressEvent.getKeyCode() == KeyEvent.VK_ENTER) {

            // Change the Type cmd prior to Typeline if the delay from the last type key is less
            // than 1 sec
            if (useTypeline && e.getModifiers() == 0 && lastElement != null) {
              String s = DocumentUtils.getElementText(lastElement);
              if (s.startsWith("Type ")
                  && (System.currentTimeMillis() - lastInsertTime) < typelineDelay) {
                replace = true;
                text = s.replaceFirst("Type", "Typeline");
              }
            }
          }

          if ("".equals(text)) {
            int count = 1;
            KeyEvent e2;

            long lastEventTime = e.getWhen();

            // We go through the vector of events and check whether there are events corresponding
            // to a typed text.
            for (int i = 0; i < events.size() && events.get(i) instanceof KeyEvent; i++) {
              e2 = (KeyEvent) events.get(i);
              if (e.getID() == e2.getID()
                  && e.getKeyChar() == e2.getKeyChar()
                  && e.getKeyCode() == e2.getKeyCode()
                  && e.getModifiers() == e2.getModifiers()
                  && (lastEventTime - e2.getWhen() < keyMutiDelay)) {
                count++;
                replace = true;
                lastEventTime = e2.getWhen();
              } else {
                break;
              }
            }

            text = "Press ";
            //                    String modifiers = KeyEvent.getKeyModifiersText(e.getModifiers());
            String modifiers = parser.modifiersToString(e.getModifiers());
            if (!"".equals(modifiers)) {
              text += modifiers + "+";
            }
            String charText = KeyEvent.getKeyText(lastKeyPressEvent.getKeyCode());
            if (charText == null) {
              charText = "<unknown>";
            }
            text += charText;
            if (count > 1) {
              text += " " + PressCommand.PARAM_COUNT + "=" + count;
            }

            if (debug) {
              System.out.println("--- RecordingModule: Inserting '" + text + "'");
            }
          }

        } else {
          text = "" + e.getKeyChar();
          KeyEvent e2;

          // We go through the vector of events and check whether there are events corresponding to
          // a typed text.
          for (int i = 0; i < events.size() && events.get(i) instanceof KeyEvent; i++) {
            e2 = (KeyEvent) events.get(i);
            if (!isControl(e2) && !e2.isActionKey()) {
              text = e2.getKeyChar() + text;
              replace = true;
            } else {
              break;
            }
          }

          text = "Type \"" + Utils.escapeUnescapedDoubleQuotes(text) + "\"";
        }

        // Insert the command to the current editor
        insertLine(text, replace, true, false);
      }
      insertEvent(e);
    }
  }
  public void keyPressed(KeyEvent e) {

    if (debug) {
      System.out.println(
          "--- RecordingModule: key pressed = "
              + e
              + "\n  > Key char->int = "
              + (int) e.getKeyChar());
    }

    // Here we process just action keys because they do not generate KEY_TYPED events.
    // Other key events are handled by the keyTyped method.
    lastInteractionTime = System.currentTimeMillis();

    if (isKeyReserved(e)) {
      return;
    }

    if (enabled && !readOnly) {
      //        System.out.println("keyPressed (e.isActionKey()=)"+e.isActionKey()+":
      // "+e.toString());
      // TODO: implement text corrections in type like Delete, Backspace

      if (e.isActionKey()) {

        if (enableKeyboard) {
          int count = 1;
          KeyEvent e2;

          long lastEventTime = e.getWhen();

          // We go through the vector of events and check whether there are events corresponding to
          // a typed text.
          for (int i = 0; i < events.size() && events.get(i) instanceof KeyEvent; i++) {
            e2 = (KeyEvent) events.get(i);
            if (e.getID() == e2.getID()
                && e.getKeyChar() == e2.getKeyChar()
                && e.getKeyCode() == e2.getKeyCode()
                && e.getModifiers() == e2.getModifiers()
                && (lastEventTime - e2.getWhen() < keyMutiDelay)) {
              count++;
              lastEventTime = e2.getWhen();
            } else {
              break;
            }
          }

          String text = "Press ";
          //                String modifiers = KeyEvent.getKeyModifiersText(e.getModifiers());
          String modifiers = parser.modifiersToString(e.getModifiers());
          if (!"".equals(modifiers)) {
            text += modifiers + "+";
          }
          String charText = (String) keyCodes.get(new Integer(e.getKeyCode()));
          if (charText == null) {
            charText = "<unknown>";
          }
          text += charText;
          if (count > 1) {
            text += " " + PressCommand.PARAM_COUNT + "=" + count;
          }
          //                text += '\n';

          if (debug) {
            System.out.println("--- RecordingModule: Inserting '" + text + "'");
          }

          // Insert the command to the current editor
          insertLine(text, count > 1, true, false);
        }
        insertEvent(e);
      }
      lastKeyPressEvent = e;
    }
  }
    // {{{ keyPressed() method
    public void keyPressed(KeyEvent evt) {
      switch (evt.getKeyCode()) {
        case KeyEvent.VK_TAB:
        case KeyEvent.VK_ENTER:
          insertSelected();
          evt.consume();
          break;
        case KeyEvent.VK_ESCAPE:
          dispose();
          evt.consume();
          break;
        case KeyEvent.VK_UP:
          int selected = words.getSelectedIndex();

          if (selected == 0) selected = words.getModel().getSize() - 1;
          else if (getFocusOwner() == words) return;
          else selected = selected - 1;

          words.setSelectedIndex(selected);
          words.ensureIndexIsVisible(selected);

          evt.consume();
          break;
        case KeyEvent.VK_DOWN:
          /* int */ selected = words.getSelectedIndex();

          if (selected == words.getModel().getSize() - 1) selected = 0;
          else if (getFocusOwner() == words) return;
          else selected = selected + 1;

          words.setSelectedIndex(selected);
          words.ensureIndexIsVisible(selected);

          evt.consume();
          break;
        case KeyEvent.VK_BACK_SPACE:
          if (word.length() == 1) {
            textArea.backspace();
            evt.consume();
            dispose();
          } else {
            word = word.substring(0, word.length() - 1);
            textArea.backspace();
            int caret = textArea.getCaretPosition();
            KeywordMap keywordMap = buffer.getKeywordMapAtOffset(caret);

            // Vector completions = getCompletions(buffer,word,
            // keywordMap,noWordSep,caret);
            Vector completions = getCompletions(word);

            if (completions.size() == 0) dispose();

            words.setListData(completions);
            words.setSelectedIndex(0);
            words.setVisibleRowCount(Math.min(completions.size(), 8));

            pack();

            evt.consume();
          }
          break;
        default:
          if (evt.isActionKey() || evt.isControlDown() || evt.isAltDown() || evt.isMetaDown()) {
            dispose();
            view.processKeyEvent(evt);
          }
          break;
      }
    }
  /**
   * Converts a new event to an old one (used for compatibility). If the new event cannot be
   * converted (because no old equivalent exists) then this returns null.
   *
   * <p>Note: this method is here instead of in each individual new event class in java.awt.event
   * because we don't want to make it public and it needs to be called from java.awt.
   */
  Event convertToOld() {
    Object src = getSource();
    int newid = id;

    switch (id) {
      case KeyEvent.KEY_PRESSED:
      case KeyEvent.KEY_RELEASED:
        KeyEvent ke = (KeyEvent) this;
        if (ke.isActionKey()) {
          newid = (id == KeyEvent.KEY_PRESSED ? Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
        }
        int keyCode = ke.getKeyCode();
        if (keyCode == KeyEvent.VK_SHIFT
            || keyCode == KeyEvent.VK_CONTROL
            || keyCode == KeyEvent.VK_ALT) {
          return null; // suppress modifier keys in old event model.
        }
        // no mask for button1 existed in old Event - strip it out
        return new Event(
            src,
            ke.getWhen(),
            newid,
            0,
            0,
            Event.getOldEventKey(ke),
            (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));

      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_MOVED:
      case MouseEvent.MOUSE_DRAGGED:
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
        MouseEvent me = (MouseEvent) this;
        // no mask for button1 existed in old Event - strip it out
        Event olde =
            new Event(
                src,
                me.getWhen(),
                newid,
                me.getX(),
                me.getY(),
                0,
                (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
        olde.clickCount = me.getClickCount();
        return olde;

      case FocusEvent.FOCUS_GAINED:
        return new Event(src, Event.GOT_FOCUS, null);

      case FocusEvent.FOCUS_LOST:
        return new Event(src, Event.LOST_FOCUS, null);

      case WindowEvent.WINDOW_CLOSING:
      case WindowEvent.WINDOW_ICONIFIED:
      case WindowEvent.WINDOW_DEICONIFIED:
        return new Event(src, newid, null);

      case ComponentEvent.COMPONENT_MOVED:
        if (src instanceof Frame || src instanceof Dialog) {
          Point p = ((Component) src).getLocation();
          return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
        }
        break;

      case ActionEvent.ACTION_PERFORMED:
        ActionEvent ae = (ActionEvent) this;
        String cmd;
        if (src instanceof Button) {
          cmd = ((Button) src).getLabel();
        } else if (src instanceof MenuItem) {
          cmd = ((MenuItem) src).getLabel();
        } else {
          cmd = ae.getActionCommand();
        }
        return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);

      case ItemEvent.ITEM_STATE_CHANGED:
        ItemEvent ie = (ItemEvent) this;
        Object arg;
        if (src instanceof List) {
          newid =
              (ie.getStateChange() == ItemEvent.SELECTED ? Event.LIST_SELECT : Event.LIST_DESELECT);
          arg = ie.getItem();
        } else {
          newid = Event.ACTION_EVENT;
          if (src instanceof Choice) {
            arg = ie.getItem();

          } else { // Checkbox
            arg = new Boolean(ie.getStateChange() == ItemEvent.SELECTED);
          }
        }
        return new Event(src, newid, arg);

      case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
        AdjustmentEvent aje = (AdjustmentEvent) this;
        switch (aje.getAdjustmentType()) {
          case AdjustmentEvent.UNIT_INCREMENT:
            newid = Event.SCROLL_LINE_DOWN;
            break;
          case AdjustmentEvent.UNIT_DECREMENT:
            newid = Event.SCROLL_LINE_UP;
            break;
          case AdjustmentEvent.BLOCK_INCREMENT:
            newid = Event.SCROLL_PAGE_DOWN;
            break;
          case AdjustmentEvent.BLOCK_DECREMENT:
            newid = Event.SCROLL_PAGE_UP;
            break;
          case AdjustmentEvent.TRACK:
            if (aje.getValueIsAdjusting()) {
              newid = Event.SCROLL_ABSOLUTE;
            } else {
              newid = Event.SCROLL_END;
            }
            break;
          default:
            return null;
        }
        return new Event(src, newid, new Integer(aje.getValue()));

      default:
    }
    return null;
  }