コード例 #1
0
  public void mouseExited(MouseEvent e) {
    // if the popup menu for is visible, don't register this,
    // because the popup being set visible will fire a mouseExited() event
    if ((popup != null) && popup.isVisible()) return;

    if (state[OPEN] != INACTIVE) {
      setState(OPEN, INACTIVE, true);
    }
    status = "";
    handleMouse(e.getX(), e.getY());
  }
コード例 #2
0
  public void mousePressed(MouseEvent e) {
    final int x = e.getX();
    final int y = e.getY();

    int sel = findSelection(x, y);
    /// if (sel == -1) return false;
    if (sel == -1) return;
    currentRollover = -1;
    // int currentSelection = sel;
    // if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
    // moving the handling of this over into the editor
    // setState(sel, ACTIVE, true);
    // }

    // if (currentSelection == OPEN) {
    // switch (currentSelection) {
    switch (sel) {
      case RUN:
        // if (!disableRun) {
        editor.handleRun(e.isShiftDown());
        // }
        break;

      case STOP:
        // if (!disableRun) {
        // setState(RUN, INACTIVE, true);
        // setInactive();
        editor.handleStop();
        // }
        break;

      case OPEN:
        if (popup == null) {
          // popup = new JPopupMenu();
          popup = editor.sketchbook.getPopupMenu();
          // no events properly being fired, so nevermind
          /*
          popup.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                System.out.println("action " + e);
              }
            });
          popup.addComponentListener(new ComponentAdapter() {
              public void componentHidden(ComponentEvent e) {
                System.out.println("hidden " + e);
              }
            });
          */
          add(popup);
        }
        // activate(OPEN);
        // SwingUtilities.invokeLater(new Runnable() {
        // public void run() {
        popup.show(EditorButtons.this, x, y);
        // }});
        break;

      case NEW:
        editor.handleNew(e.isShiftDown());
        break;

      case SAVE:
        editor.handleSave(false);
        break;

      case EXPORT:
        editor.handleExport();
        break;

      case SERIAL:
        editor.handleSerial();
        break;
    }
  }