Exemple #1
0
  public void mousePressed(MouseEvent e) {
    
    // jdf
    if (!isEnabled())
      return;
    
    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;

    switch (sel) {
    case RUN:
      editor.handleRun(e.isShiftDown());
      break;

//    case STOP:
//      editor.handleStop();
//      break;
//
    case OPEN:
      popup = menu.getPopupMenu();
      popup.show(EditorToolbar.this, x, y);
      break;

    case NEW:
      if (shiftPressed) {
        editor.base.handleNew();
      } else {
      editor.base.handleNewReplace();
      }
      break;

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

    case EXPORT:
      boolean t = e.isControlDown();
      editor.handleExport(e.isShiftDown(),autoOpenSerialMonitor ? !t : t); // Control is down if autoOpenSerialMonitor is true in preferences
      break;

    case SERIAL:
      editor.handleSerial();
      handleMouse(e);
      break;
    }
  }
  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;
    }
  }