コード例 #1
0
  /**
   * @param e mouse event
   * @param geo geo
   * @return true if left press can select the geo
   */
  protected boolean leftPressCanSelectGeo(java.awt.event.MouseEvent e, GeoElement geo) {

    if (!AppD.isControlDown(e) && !e.isShiftDown()) {
      if (!setSelectedGeo(geo)) return true;
    }

    return false;
  }
コード例 #2
0
  @Override
  protected boolean leftPressCanSelectGeo(java.awt.event.MouseEvent e, GeoElement geo) {

    int mode = app.getActiveEuclidianView().getMode();
    if ((mode == EuclidianConstants.MODE_MOVE || mode == EuclidianConstants.MODE_SELECTION_LISTENER)
        && !AppD.isControlDown(e)
        && !e.isShiftDown()) {
      if (!setSelectedGeo(geo)) return true;
    }
    return false;
  }
コード例 #3
0
  public void mouseDragged(MouseEvent e) {
    e.consume();

    // update selection
    int mouseDraggedRow = rowHeader.locationToIndex(e.getPoint());

    // make sure mouse pressed is initialized, this may not be the case
    // after closing the popup menu
    if (mousePressedRow < 0) {
      table.stopEditing();
      mousePressedRow = mouseDraggedRow;
    }
    if (AppD.isControlDown(e)) rowHeader.addSelectionInterval(mousePressedRow, mouseDraggedRow);
    else rowHeader.setSelectionInterval(mousePressedRow, mouseDraggedRow);
  }
コード例 #4
0
 @Override
 protected boolean checkDoubleClick(GeoElement geo, MouseEvent e) {
   // check double click
   int clicks = e.getClickCount();
   // EuclidianView ev = app.getEuclidianView();
   EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView();
   if (clicks == 2) {
     selection.clearSelectedGeos(true, false);
     app.updateSelection(false);
     ev.resetMode();
     if (geo != null && !AppD.isControlDown(e)) {
       view.startEditing(geo, e.isShiftDown());
     }
     return true;
   }
   return false;
 }
コード例 #5
0
  /*
   * MouseListener implementation for popup menus
   */
  public void mouseClicked(java.awt.event.MouseEvent e) {
    // right click is consumed in mousePressed, but in GeoGebra 3D,
    // where heavyweight popup menus are enabled this doesn't work
    // so make sure that this is no right click as well (ticket #302)
    if (e.isConsumed() || AppD.isRightClick(e)) {
      return;
    }

    // get GeoElement at mouse location
    TreePath tp = tree.getPathForLocation(e.getX(), e.getY());
    GeoElement geo = AlgebraTree.getGeoElementForPath(tp);

    ArrayList<GeoElement> groupedGeos = null;

    // check if we clicked on the 16x16 show/hide icon
    if (geo != null) {
      Rectangle rect = tree.getPathBounds(tp);
      boolean iconClicked = rect != null && e.getX() - rect.x < 16; // distance from left border		
      if (iconClicked) {
        // icon clicked: toggle show/hide
        geo.setEuclidianVisible(!geo.isSetEuclidianVisible());
        geo.updateVisualStyle();
        app.storeUndoInfo();
        kernel.notifyRepaint();
        return;
      }

    } else { // try group action
      groupedGeos = groupAction(e, tp, false);
    }

    // check double click
    if (checkDoubleClick(geo, e)) return;

    EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView();
    int mode = ev.getMode();
    if (!skipSelection && isSelectionModeForClick(mode)) {
      // update selection
      if (geo == null) {
        if (!AppD.isControlDown(e) && !e.isShiftDown()) app.clearSelectedGeos();

        if (groupedGeos != null) app.addSelectedGeos(groupedGeos, true);

      } else {
        // handle selecting geo
        if (AppD.isControlDown(e)) {
          app.toggleSelectedGeo(geo);
          if (app.getSelectedGeos().contains(geo)) lastSelectedGeo = geo;
        } else if (e.isShiftDown() && lastSelectedGeo != null) {
          ArrayList<GeoElement> geos = tree.getGeosBetween(lastSelectedGeo, geo);
          if (geos != null) {
            app.clearSelectedGeos(false); // repaint will be done next step
            app.addSelectedGeos(geos, true);
          }

        } else {
          app.clearSelectedGeos(false); // repaint will be done next step
          app.addSelectedGeo(geo);
          lastSelectedGeo = geo;
        }
      }
    } else if (mode != EuclidianConstants.MODE_SELECTION_LISTENER) {
      euclidianViewClick(ev, geo, e);
    } else
      // tell selection listener about click
      app.geoElementSelected(geo, false);

    // Alt click: copy definition to input field
    if (geo != null && e.isAltDown() && app.showAlgebraInput()) {
      // F3 key: copy definition to input bar
      app.getGlobalKeyDispatcher().handleFunctionKeyForAlgebraInput(3, geo);
    }

    ev.mouseMovedOver(null);
  }