Java Code Examples for com.google.gwt.dom.client.NativeEvent#BUTTON_RIGHT

The following examples show how to use com.google.gwt.dom.client.NativeEvent#BUTTON_RIGHT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiagramController.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void onMouseDown(MouseDownEvent event) {
	// Test if Right Click
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		return;
	}

	if (inEditionSelectableShapeToDrawConnection) {
		inDragBuildArrow = true;
		inEditionSelectableShapeToDrawConnection = false;
		drawBuildArrow(startFunctionWidget, mousePoint);
		return;
	}

	if (inEditionDragMovablePoint) {
		inDragMovablePoint = true;
		inEditionDragMovablePoint = false;
		movablePoint = highlightConnection.addMovablePoint(highlightPoint);
		highlightConnection.setSynchronized(false);
		highlightConnection.setAllowSynchronized(false);
		movablePoint.setTrackPoint(mousePoint);
		// Set canvas foreground to avoid dragging over a widget
		topCanvas.setForeground();
		return;
	}
}
 
Example 2
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger action when mouse up event fired
 * 
 * @param event
 */
protected void onMouseUp(MouseUpEvent event) {
	// Test if Right Click
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		logger.info( "Handle NativeEvent.BUTTON_RIGHT begin >");
		event.stopPropagation();
		event.preventDefault();
		logger.info("Handle NativeEvent.BUTTON_RIGHT end <");
		return;
	}

	if ( !lockDrawConnection && inDragBuildConnection ) {
		logger.info( "draw connection lock: " +  lockDrawConnection );
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape != null && shape instanceof InNodeShape) {
			Connection c = connfactory.buildConnection(this, startShape, shape);
			if (c == null) {
				Window.alert("Connection can't be build");
			} else {
				c.draw();
				connDrawSet.add(c);
				((NodeShape) startShape).onConnectionEnd(c);
				shape.onConnectionEnd(c);
			}
		}else {
			((NodeShape) startShape).onConnectionCancel();
		}
		deleteConnection(buildConnection);
		inDragBuildConnection = false;
		buildConnection = null;
	}
}
 
Example 3
Source File: MonitorController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
	super.onMouseUp(event);
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape instanceof OutNodeShape) {
			OutNodeShape outShape = (OutNodeShape)shape;
			int x = outShape.getOffsetLeft() + 2*outShape.getRadius();
			int y = outShape.getOffsetTop() + 2*outShape.getRadius();
			outShape.getContextMenu().setPopupPosition(x,y);
			outShape.getContextMenu().show();
		}
	}
}
 
Example 4
Source File: DatasetWidget.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {

	super.onMouseDown(event);
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		event.stopPropagation();
		event.preventDefault();
	}

	DiagramController con =this.getController();
	con.setPropTable(ptable);
}
 
Example 5
Source File: BaseWidget.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		event.stopPropagation();
		event.preventDefault();
		controller.showMenu(this);
		this.setFocus();
	}
}
 
Example 6
Source File: CirSim.java    From circuitjs1 with GNU General Public License v2.0 4 votes vote down vote up
public void mouseDragged(MouseMoveEvent e) {
  	// ignore right mouse button with no modifiers (needed on PC)
  	if (e.getNativeButton()==NativeEvent.BUTTON_RIGHT) {
  		if (!(e.isMetaKeyDown() ||
  				e.isShiftKeyDown() ||
  				e.isControlKeyDown() ||
  				e.isAltKeyDown()))
  			return;
  	}
  	
  	if (tempMouseMode==MODE_DRAG_SPLITTER) {
  		dragSplitter(e.getX(), e.getY());
  		return;
  	}
  	int gx = inverseTransformX(e.getX());
  	int gy = inverseTransformY(e.getY());
  	if (!circuitArea.contains(e.getX(), e.getY()))
  	    return;
  	boolean changed = false;
  	if (dragElm != null)
  	    dragElm.drag(gx, gy);
  	boolean success = true;
  	switch (tempMouseMode) {
  	case MODE_DRAG_ALL:
  		dragAll(e.getX(), e.getY());
  		break;
  	case MODE_DRAG_ROW:
  		dragRow(snapGrid(gx), snapGrid(gy));
  		changed = true;
  		break;
  	case MODE_DRAG_COLUMN:
dragColumn(snapGrid(gx), snapGrid(gy));
  		changed = true;
  		break;
  	case MODE_DRAG_POST:
  		if (mouseElm != null) {
  		    dragPost(snapGrid(gx), snapGrid(gy));
  		    changed = true;
  		}
  		break;
  	case MODE_SELECT:
  		if (mouseElm == null)
  		    selectArea(gx, gy);
  		else {
  		    // wait short delay before dragging.  This is to fix problem where switches were accidentally getting
  		    // dragged when tapped on mobile devices
  		    if (System.currentTimeMillis()-mouseDownTime < 150)
  			return;
  		
  		    tempMouseMode = MODE_DRAG_SELECTED;
  		    changed = success = dragSelected(gx, gy);
  		}
  		break;
  	case MODE_DRAG_SELECTED:
  		changed = success = dragSelected(gx, gy);
  		break;

  	}
  	dragging = true;
  	if (success) {
  	    dragScreenX = e.getX();
  	    dragScreenY = e.getY();
  //	    console("setting dragGridx in mousedragged");
  	    dragGridX = inverseTransformX(dragScreenX);
  	    dragGridY = inverseTransformY(dragScreenY);
  	    if (!(tempMouseMode == MODE_DRAG_SELECTED && onlyGraphicsElmsSelected())) {
  		dragGridX = snapGrid(dragGridX);
  		dragGridY = snapGrid(dragGridY);
  	    }
 	}
  	if (changed)
  	    writeRecoveryToStorage();
  	repaint();
  }
 
Example 7
Source File: DiagramController.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void onMouseUp(MouseUpEvent event) {

		// Test if Right Click
		if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
			event.stopPropagation();
			event.preventDefault();
			showContextualMenu();
			return;
		}

		if (inDragMovablePoint) {
			movablePoint.setFixed(true);
			topCanvas.setBackground();
			inDragMovablePoint = false;
			highlightConnection.setAllowSynchronized(true);
			return;
		}

		if (inDragBuildArrow) {
			FunctionShape functionUnderMouse = getShapeUnderMouse();
			if (functionUnderMouse != null) {
				Widget widgetSelected = functionUnderMouse.asWidget();
				if (startFunctionWidget != widgetSelected) {
					Connection c = drawStraightArrowConnection(startFunctionWidget, widgetSelected, (String) null);
					fireEvent(new TieLinkEvent(startFunctionWidget, widgetSelected, c));
				}
			}
			topCanvas.setBackground();
			deleteConnection(buildConnection);
			inDragBuildArrow = false;
			buildConnection = null;
			if (highlightFunctionShape != null) {
				highlightFunctionShape.draw();
				highlightFunctionShape = null;
			}
			clearAnimationsOnCanvas();
		}

		if (inEditionDragMovablePoint) {
			inEditionDragMovablePoint = false;
			clearAnimationsOnCanvas();
		}
	}
 
Example 8
Source File: DiagramController.java    From EasyML with Apache License 2.0 4 votes vote down vote up
/**
 * Trigger action when mouse down event fired
 * 
 * @param event
 */
public void onMouseDown(MouseDownEvent event) {
	logger.info("diagram left mouse down");
	this.getWidgetPanel().getElement().focus();
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape instanceof OutNodeShape) {
			OutNodeShape outShape = (OutNodeShape)shape;
			int x = outShape.getOffsetLeft() + 2*outShape.getRadius();
			int y = outShape.getOffsetTop() + 2*outShape.getRadius();
			outShape.getContextMenu().setPopupPosition(x,y);
			outShape.getContextMenu().show();
		}
		if(isvacancy){
			event.stopPropagation();
			event.preventDefault();
			//Popup connection menu
			if( !this.inShapeArea ){
				final Connection c = getConnectionNearMouse();
				if (c != null) {
					showMenu(c);
				}else{
					showContextualMenu(event);
				}
			}

		}

		return;
	}

	if (!lockDrawConnection && inEditionToDrawConnection) {
		logger.info( "draw connection lock: " +  lockDrawConnection );
		inDragBuildConnection = true;
		inEditionToDrawConnection = false;
		((NodeShape) startShape).onConnectionStart();
		drawBuildArrow(startShape, getMousePoint());
	}
	if(!isvacancy){
		event.stopPropagation();
		event.preventDefault();
		focusTimer.scheduleRepeating(50);
	}
	else {
		this.clearSelectedWidgets();
		selectedWidget = null;
		focusTimer.scheduleRepeating(50);
	}
	this.setIsVacancy(true);
}