Example #1
0
  public void mouseClicked(MouseEvent e) {
    int x;
    int y;

    e.consume();

    if (mouseEventsEnabled) {

      x = Math.round(e.getX() / scale);
      y = Math.round(e.getY() / scale);

      // allow for the canvas margin
      y -= margin;

      // System.out.println("Mouse Click: (" + x + ", " + y + ")");

      if (e.getClickCount() < 2) {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }
      } else {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }

        editSelected();
        parentFTAFrame.updateFrame();
      }

      if (focusEventsEnabled) {
        // tell the main Canvas to point to this coordinate
        parentFTAFrame.setCanvasFocus(x, y);
      }
    }
  }
Example #2
0
 public void mousePressed(MouseEvent e) {
   int x = e.getX(), y = e.getY();
   pressX = lastX = x;
   pressY = lastY = y;
   first = findFigureElement(x, y);
   if (first == null) {
     point1 = addPoint(x, y);
   }
 }
 @Override
 public void mouseClicked(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     String ip = (String) as.getAttribute("ip");
     ScriptException se = (ScriptException) as.getAttribute("exception");
     Node node = net.getAtIP(ip);
     if (node == null) {
       Utility.displayError("Error", "Computer does not exist");
       return;
     }
     String errorString =
         "--ERROR--\n"
             + "Error at line number "
             + se.getLineNumber()
             + " and column number "
             + se.getColumnNumber()
             + "\n"
             + se.getMessage();
     new ScriptDialog(
             parentFrame,
             str -> {
               if (str != null) {
                 node.setScript(str);
               }
             },
             node.getScript(),
             errorString)
         .setVisible(true);
   }
 }
 void jListOnlineUsers_mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {
     jTextFieldTargetUser.setText(((HostItem) jListOnlineUsers.getSelectedValue()).name);
     Flasher.instance().flashBackground(jTextFieldTargetUser, Color.yellow, 2);
     jTextFieldSendMessages.requestFocus();
   }
 }
Example #5
0
 // This fixes the problem where when on the mac you have to ctrl left click to
 // get popup triggers the caret has code that only looks at button number.
 // see radar # 3125390
 @Override
 public void mousePressed(final MouseEvent e) {
   if (!e.isPopupTrigger()) {
     super.mousePressed(e);
     shouldSelectAllOnFocus = false;
   }
 }
Example #6
0
 public void mouseDragged(MouseEvent e) {
   int x = e.getX(), y = e.getY(), dx = lastX - x, dy = lastY - y;
   lastX = x;
   lastY = y;
   if (first == null) {
     Line line = addLine(point1, new Point(x, y));
     if (line != null) {
       canvas.add(line.getP2());
       first = line.getP2();
       canvas.add(line);
     }
   } else {
     first.move(-dx, -dy);
   }
   repaint();
 }
Example #7
0
 public void mouseClicked(MouseEvent e) {
   if (e.getSource() == bottomText) {
     try {
       getAppletContext().showDocument(new URL(linkURL), "_blank");
     } catch (java.net.MalformedURLException ex) {
     }
   } else {
     maybeShowPopup(e);
   }
 }
 public void mouseReleased(MouseEvent e) {
   if (e.getButton() == e.BUTTON1 && connected) {
     if (dec == null) return;
     lc.increment();
     TextEvent cu = new CaretUpdate(area1.getCaretPosition(), lc.getTimeStamp());
     dec.sendObjectToAllPeers(cu);
     er.getEventHistoryLock().lock();
     er.getEventHistory().add(cu);
     er.getEventHistoryLock().unlock();
   }
 }
 @Override
 public void mouseMoved(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     setCursor(handCursor);
   } else {
     setCursor(defaultCursor);
   }
 }
Example #10
0
 public Element getLineAtPoint(MouseEvent me) {
   Point p = me.getLocationOnScreen();
   Point pp = getLocationOnScreen();
   p.translate(-pp.x, -pp.y);
   int pos = viewToModel(p);
   Element root = getDocument().getDefaultRootElement();
   int e = root.getElementIndex(pos);
   if (e == -1) {
     return null;
   }
   return root.getElement(e);
 }
Example #11
0
    public void mousePressed(MouseEvent evt) {
      requestFocus();

      // Focus events not fired sometimes?
      setCaretVisible(true);
      focusedComponent = JEditTextArea.this;

      if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 && popup != null) {
        popup.show(painter, evt.getX(), evt.getY());
        return;
      }

      int line = yToLine(evt.getY());
      int offset = xToOffset(line, evt.getX());
      int dot = getLineStartOffset(line) + offset;

      switch (evt.getClickCount()) {
        case 1:
          doSingleClick(evt, line, offset, dot);
          break;
        case 2:
          // It uses the bracket matching stuff, so
          // it can throw a BLE
          try {
            doDoubleClick(evt, line, offset, dot);
          } catch (BadLocationException bl) {
            bl.printStackTrace();
          }
          break;
        case 3:
          doTripleClick(evt, line, offset, dot);
          break;
      }
    }
 /** Select or grow image when clicked. */
 public void mousePressed(MouseEvent e) {
   Dimension size = fComponent.getSize();
   if (e.getX() >= size.width - 7 && e.getY() >= size.height - 7 && getSelectionState() == 2) {
     // Click in selected grow-box:
     if (DEBUG) System.out.println("ImageView: grow!!! Size=" + fWidth + "x" + fHeight);
     Point loc = fComponent.getLocationOnScreen();
     fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);
     fGrowProportionally = e.isShiftDown();
   } else {
     // Else select image:
     fGrowBase = null;
     JTextComponent comp = (JTextComponent) fContainer;
     int start = fElement.getStartOffset();
     int end = fElement.getEndOffset();
     int mark = comp.getCaret().getMark();
     int dot = comp.getCaret().getDot();
     if (e.isShiftDown()) {
       // extend selection if shift key down:
       if (mark <= start) comp.moveCaretPosition(end);
       else comp.moveCaretPosition(start);
     } else {
       // just select image, without shift:
       if (mark != start) comp.setCaretPosition(start);
       if (dot != end) comp.moveCaretPosition(end);
     }
   }
 }
  /** Resize image if initial click was in grow-box: */
  public void mouseDragged(MouseEvent e) {
    if (fGrowBase != null) {
      Point loc = fComponent.getLocationOnScreen();
      int width = Math.max(2, loc.x + e.getX() - fGrowBase.x);
      int height = Math.max(2, loc.y + e.getY() - fGrowBase.y);

      if (e.isShiftDown() && fImage != null) {
        // Make sure size is proportional to actual image size:
        float imgWidth = fImage.getWidth(this);
        float imgHeight = fImage.getHeight(this);
        if (imgWidth > 0 && imgHeight > 0) {
          float prop = imgHeight / imgWidth;
          float pwidth = height / prop;
          float pheight = width * prop;
          if (pwidth > width) width = (int) pwidth;
          else height = (int) pheight;
        }
      }

      resize(width, height);
    }
  }
Example #14
0
  /**
   * Re-dispatches glass pane mouse events only in case they occur on the security panel.
   *
   * @param glassPane the glass pane
   * @param e the mouse event in question
   */
  private void redispatchMouseEvent(Component glassPane, MouseEvent e) {
    Point glassPanePoint = e.getPoint();

    Point securityPanelPoint =
        SwingUtilities.convertPoint(glassPane, glassPanePoint, securityPanel);

    Component component;
    Point componentPoint;

    if (securityPanelPoint.y > 0) {
      component = securityPanel;
      componentPoint = securityPanelPoint;
    } else {
      Container contentPane =
          callRenderer.getCallContainer().getCallWindow().getFrame().getContentPane();

      Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);

      component =
          SwingUtilities.getDeepestComponentAt(contentPane, containerPoint.x, containerPoint.y);

      componentPoint = SwingUtilities.convertPoint(contentPane, glassPanePoint, component);
    }

    if (component != null)
      component.dispatchEvent(
          new MouseEvent(
              component,
              e.getID(),
              e.getWhen(),
              e.getModifiers(),
              componentPoint.x,
              componentPoint.y,
              e.getClickCount(),
              e.isPopupTrigger()));

    e.consume();
  }
Example #15
0
    public void mouseDragged(MouseEvent evt) {
      if (popup != null && popup.isVisible()) return;

      setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0);
      select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY()));
    }
 /** On double-click, open image properties dialog. */
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) {}
 }
Example #17
0
 public void mouseEntered(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
 }
Example #18
0
 public void mouseExited(MouseEvent e) {
   if (e.getSource() == bottomText) {
     bottomText.setCursor(Cursor.getDefaultCursor());
   }
 }
Example #19
0
 /** Checks to see if the event was to show the popup menu */
 private void maybeShowPopup(MouseEvent e) {
   if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
     popup.show(userList, e.getX(), e.getY());
   }
 }
 void jTextPaneDisplayMessages_mouseClicked(MouseEvent e) {
   if ((e.getModifiers() & Event.META_MASK) == Event.META_MASK) {
     jPopupMenuMessageArea.show(jTextPaneDisplayMessages, e.getX(), e.getY());
   }
 }
Example #21
0
 private void doSingleClick(MouseEvent evt, int line, int offset, int dot) {
   if ((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) {
     rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0;
     select(getMarkPosition(), dot);
   } else setCaretPosition(dot);
 }
Example #22
0
 public void mouseReleased(MouseEvent aEvent) {
   if (aEvent.isPopupTrigger())
     contextMenu.show((Component) aEvent.getSource(), aEvent.getX(), aEvent.getY());
 }
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }