@Override protected void euclidianViewClick(EuclidianViewInterfaceCommon ev, GeoElement geo, MouseEvent e) { // let euclidianView know about the click AbstractEvent event = geogebra.euclidian.event.MouseEvent.wrapEvent(e); ev.clickedGeo(geo, event); event.release(); // if click created a geo, notify app to select it ev.getEuclidianController().setJustCreatedGeosSelected(); }
// tell EuclidianView public void mouseMoved(AbstractEvent e) { if (view.isEditing()) return; int x = e.getX(); int y = e.getY(); GeoElement geo = view.getGeoElementForLocation(view, x, y); // tell EuclidianView to handle mouse over // EuclidianView ev = app.getEuclidianView(); EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView(); ev.mouseMovedOver(geo); if (geo != null) { app.setTooltipFlag(); // FIXMEview.setToolTipText(geo.getLongDescriptionHTML(true, true)); app.clearTooltipFlag(); } // FIXMEelse // FIXMEview.setToolTipText(null); }
public void mouseClicked(AbstractEvent 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() FIXME||*/ e.isRightClick()) { return; } // get GeoElement at mouse location Object tp = view.getPathForLocation(e.getX(), e.getY()); GeoElement geo = view.getGeoElementForPath(tp); // check if we clicked on the 16x16 show/hide icon if (geo != null) { GRectangle rect = (GRectangle) view.getPathBounds(tp); boolean iconClicked = rect != null && e.getX() - rect.getX() < 16; // distance from left border if (iconClicked) { // icon clicked: toggle show/hide geo.setEuclidianVisible(!geo.isSetEuclidianVisible()); geo.updateVisualStyle(); app.storeUndoInfo(); kernel.notifyRepaint(); return; } } // check double click int clicks = e.getClickCount(); // EuclidianView ev = app.getEuclidianView(); EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView(); if (clicks == 2) { app.clearSelectedGeos(); ev.resetMode(); if (geo != null && !e.isControlDown()) { view.startEditing(geo, e.isShiftDown()); } return; } int mode = ev.getMode(); if (!skipSelection && (mode == EuclidianConstants.MODE_MOVE || mode == EuclidianConstants.MODE_RECORD_TO_SPREADSHEET)) { // update selection if (geo == null) { app.clearSelectedGeos(); } else { // handle selecting geo if (e.isControlDown()) { app.toggleSelectedGeo(geo); if (app.getSelectedGeos().contains(geo)) lastSelectedGeo = geo; } else if (e.isShiftDown() && lastSelectedGeo != null) { boolean nowSelecting = true; boolean selecting = false; boolean aux = geo.isAuxiliaryObject(); boolean ind = geo.isIndependent(); boolean aux2 = lastSelectedGeo.isAuxiliaryObject(); boolean ind2 = lastSelectedGeo.isIndependent(); if ((aux == aux2 && aux) || (aux == aux2 && ind == ind2)) { Iterator<GeoElement> it = kernel.getConstruction().getGeoSetLabelOrder().iterator(); boolean direction = geo.getLabel(StringTemplate.defaultTemplate) .compareTo(lastSelectedGeo.getLabel(StringTemplate.defaultTemplate)) < 0; while (it.hasNext()) { GeoElement geo2 = it.next(); if ((geo2.isAuxiliaryObject() == aux && aux) || (geo2.isAuxiliaryObject() == aux && geo2.isIndependent() == ind)) { if (direction && geo2.equals(lastSelectedGeo)) selecting = !selecting; if (!direction && geo2.equals(geo)) selecting = !selecting; if (selecting) { app.toggleSelectedGeo(geo2); nowSelecting = app.getSelectedGeos().contains(geo2); } if (!direction && geo2.equals(lastSelectedGeo)) selecting = !selecting; if (direction && geo2.equals(geo)) selecting = !selecting; } } } if (nowSelecting) { app.addSelectedGeo(geo); lastSelectedGeo = geo; } else { app.removeSelectedGeo(lastSelectedGeo); lastSelectedGeo = null; } } else { app.clearSelectedGeos(false); // repaint will be done next step app.addSelectedGeo(geo); lastSelectedGeo = geo; } } } else if (mode != EuclidianConstants.MODE_SELECTION_LISTENER) { // let euclidianView know about the click AbstractEvent event = e; ev.clickedGeo(geo, event); event.release(); } 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); }
public void mousePressed(AbstractEvent e) { view.cancelEditing(); boolean rightClick = app.isRightClickEnabled() && e.isRightClick(); // RIGHT CLICK if (rightClick) { /*e.consume(); FIXME*/ // get GeoElement at mouse location Object tp = view.getPathForLocation(e.getX(), e.getY()); GeoElement geo = view.getGeoElementForPath(tp); if (geo != null && !app.containsSelectedGeo(geo)) { app.clearSelectedGeos(); } // single selection: popup menu if (app.selectedGeosSize() < 2) { /* if(geo == null) { AlgebraContextMenu contextMenu = new AlgebraContextMenu(app); contextMenu.show(view, e.getPoint().x, e.getPoint().y); } else { ArrayList<GeoElement> temp = new ArrayList<GeoElement>(); temp.add(geo); app.getGuiManager().showPopupMenu(temp, view, mouseCoords); } */ } // multiple selection: popup menu (several geos) else { if (geo != null) { // app.getGuiManager().showPopupMenu(app.getSelectedGeos(), view, mouseCoords); } } // LEFT CLICK } else { // When a single, new selection is made with no key modifiers // we need to handle selection in mousePressed, not mouseClicked. // By doing this selection early, a DnD drag will come afterwards // and grab the new selection. // All other selection types must be handled later in mouseClicked. // In this case a DnD drag starts first and grabs the previously selected // geos (e.g. cntrl-selected or EV selected) as the user expects. skipSelection = false; // flag to prevent duplicate selection in MouseClicked Object tp = view.getPathForLocation(e.getX(), e.getY()); GeoElement geo = view.getGeoElementForPath(tp); EuclidianViewInterfaceCommon ev = app.getActiveEuclidianView(); int mode = ev.getMode(); if ((mode == EuclidianConstants.MODE_MOVE || mode == EuclidianConstants.MODE_SELECTION_LISTENER) && !e.isControlDown() && !e.isShiftDown() && geo != null && !app.containsSelectedGeo(geo)) { app.clearSelectedGeos(false); // repaint will be done next step app.addSelectedGeo(geo); lastSelectedGeo = geo; skipSelection = true; } } }