@Override
public void mousePressed(MouseEvent e){
      SimSession session = frame.session;
      int mask = e.getModifiers();
      int button;
      // note that all buttons are mapped as if we were dealing with
      // a two button mouse.   On systems with 3 buttons (X-Windows)
      // the right two buttons are mapped to the same value.
      // On the one-button Macintosh, using the ALT key causes
      // the application to interpret the key press as if it were
      // the right button.

      if((mask&InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK){
         button=0;
         if((mask & InputEvent.ALT_MASK) == InputEvent.ALT_MASK)
            button=1;
         else if ((mask & InputEvent.META_MASK) == InputEvent.META_MASK)
            button=1;
         else
            button = 0;
      }else if((mask&InputEvent.BUTTON2_MASK)==InputEvent.BUTTON2_MASK)
         button=1;
      else if((mask&InputEvent.BUTTON3_MASK)==InputEvent.BUTTON3_MASK)
         button=1;
      else
         button=0;

      RsPoint p = frame.canvas.inverseMap(e.getX(), e.getY());
      // e.consume();

      // send an RsMouseClickEvent to any interested clients.

      RsMouseClickEvent mce = new RsMouseClickEvent(
         session.scheduler.getUpdatedSimTime(),
         button,
         e.getClickCount(),
         p.x, p.y);
      SimMouseClickTask smt = new SimMouseClickTask(session, mce);
      session.scheduler.add(smt);
   }