예제 #1
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;
      }
    }
예제 #2
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);
 }
예제 #3
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()));
    }