Java Code Examples for processing.event.MouseEvent#RELEASE

The following examples show how to use processing.event.MouseEvent#RELEASE . 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: PScene.java    From Project-16x16 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method is <b>Public</b> only to enable binding to a parent PApplet.
 * <p>
 * You can <b>ignore this method</b> since the parent sketch will call it
 * automatically when it detects a mouse event (provided register() has been
 * called).
 */
public final void mouseEvent(MouseEvent e) {
	switch (e.getAction()) {
		case MouseEvent.PRESS :
			mousePressed(e);
			break;
		case MouseEvent.RELEASE :
			mouseReleased(e);
			break;
		case MouseEvent.CLICK :
			mouseClicked(e);
			break;
		case MouseEvent.WHEEL :
			mouseWheel(e);
			break;
		case MouseEvent.DRAG :
			mouseDragged(e);
			break;
		default :
			break;
	}
}
 
Example 2
Source File: DwColorPicker.java    From PixelFlow with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent me) {
  int mx_global = me.getX();
  int my_global = me.getY();
  int mx = mx_global - cp_x;
  int my = my_global - cp_y;
  
  if(me.getAction() == MouseEvent.PRESS){
    SELECTION_ACTIVE = inside(mx, my);
    cb_mouseEvent(me);
  }
  if(me.getAction() == MouseEvent.RELEASE){
    SELECTION_ACTIVE = false;
    cb_mouseEvent(me);
  }
  
  if(SELECTION_ACTIVE){
    selectColorByCoords(mx, my);
    LAST_USED = this;
    cb_mouseEvent(me);
  }

}
 
Example 3
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 6 votes vote down vote up
public void checkMouseDragPoint(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		break;
	case MouseEvent.RELEASE:
		if(SELECTED_POINT != null) save();
		SELECTED_POINT = null;
		break;
	case MouseEvent.MOVE:
		checkMouseHoverPoint();
		break;
	case MouseEvent.DRAG:
		if( SELECTED_POINT != null ) {
			SELECTED_POINT.setLocation( mousePoint );
			updateCenter();
		}
		break;
	}
}
 
Example 4
Source File: BaseSavedQuadUI.java    From haxademic with MIT License 6 votes vote down vote up
public void checkMouseDragQuad(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(isHovered == true && SELECTED_POINT == null) {
			DRAGGING_QUAD = this;
			mouseDragged.setLocation(mousePoint.x, mousePoint.y);
			updateCenter();
		}
		break;
	case MouseEvent.RELEASE:
		if(DRAGGING_QUAD != null) save();
		DRAGGING_QUAD = null;
		break;
	case MouseEvent.DRAG:
		if(DRAGGING_QUAD == this) {
			mouseDragged.setLocation(mousePoint.x - mouseDragged.x, mousePoint.y - mouseDragged.y);
			for( int i=0; i < points.length; i++ ) {
				points[i].translate(mouseDragged.x, mouseDragged.y);
			}
			mouseDragged.setLocation(mousePoint.x, mousePoint.y);
			updateCenter();
		}
		break;
	}
}
 
Example 5
Source File: SavedPointUI.java    From haxademic with MIT License 6 votes vote down vote up
public void checkMouseDrag(MouseEvent event) {
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(isHovered == true) {
			DRAGGING_POINT = this;
		}
		break;
	case MouseEvent.DRAG:
		if(DRAGGING_POINT == this) {
			position.set(mousePoint.x, mousePoint.y);
		}
		break;
	case MouseEvent.RELEASE:
		if(DRAGGING_POINT == this) save();
		DRAGGING_POINT = null;
		break;
	}
}
 
Example 6
Source File: MouseShutdown.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
  // int x = event.getX();
  // int y = event.getY();

  switch (event.getAction()) {
    case MouseEvent.PRESS:
      break;
    case MouseEvent.RELEASE:
      break;
    case MouseEvent.CLICK:
    	click();
      break;
    case MouseEvent.DRAG:
      break;
    case MouseEvent.MOVE:
      break;
  }
}
 
Example 7
Source File: UIButton.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(!isActive()) return;
	
	int mouseX = event.getX();
	int mouseY = event.getY();

	switch (event.getAction()) {
		case MouseEvent.PRESS:
			pressed = rect.contains(mouseX, mouseY);
			break;
		case MouseEvent.RELEASE:
			if(pressed && over) click();
			pressed = false;
			break;
		case MouseEvent.MOVE:
			over = rect.contains(mouseX, mouseY);
			break;
		case MouseEvent.DRAG:
			over = rect.contains(mouseX, mouseY);
			break;
	}
}
 
Example 8
Source File: UISlider.java    From haxademic with MIT License 6 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(isActive() == false) return;
	// collision detection
	mousePoint.setLocation(event.getX(), event.getY());
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(uiRect.contains(mousePoint)) mousePressed = true;
		break;
	case MouseEvent.RELEASE:
		if(mousePressed) {
			mousePressed = false;
			if(saves) PrefToText.setValue(id, value);
		}
		break;
	case MouseEvent.MOVE:
		mouseHovered = uiRect.contains(mousePoint);
		break;
	case MouseEvent.DRAG:
		if(mousePressed) {
			float deltaX = (P.p.mouseX - P.p.pmouseX) * dragStep;
			value += deltaX;
			value = P.constrain(value, valueMin, valueMax);
		}
		break;
	}
}
 
Example 9
Source File: ProcessingTouchEvents.java    From Circle-Synth with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Mouse event listener
 * @param event MouseEvent
 */
public void mouseEvent(MouseEvent event) {

	switch (event.getAction()) {

	case MouseEvent.PRESS:
		mX = event.getX();
		mY = event.getY();
		touchDown(mX, mY);

		break;

	case MouseEvent.RELEASE:
		mX = event.getX();
		mY = event.getY();
		touchUp(mX, mY);
	}
}
 
Example 10
Source File: SavedRectangle.java    From haxademic with MIT License 5 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	switch (event.getAction()) {
		case MouseEvent.PRESS:
			mouseStartPoint.setLocation( event.getX() + rectOffset.x, event.getY() + rectOffset.y );
			if(rectangle.contains(mouseStartPoint) && SavedRectangle.curDragging == null) {
				isDragging = true;
				SavedRectangle.curDragging = this;
				float cornerClickDist = (float) mouseStartPoint.distance(rectangle.x + rectangle.width, rectangle.y + rectangle.height);
				if(cornerClickDist < 15) {
					isResizing = true;
				} 
				rectangleMove = new Rectangle(rectangle); // build temp rectangle for moving
			}
			break;
		case MouseEvent.RELEASE:
			if(isDragging == true) {
				updateRectangle(rectangleMove);
				SavedRectangle.curDragging = null;
				rectangleMove = null;
				isDragging = false;
				isResizing = false;
			}
			break;
		case MouseEvent.MOVE:
			break;
		case MouseEvent.DRAG:
			if(isDragging == true) {
				mouseMovePoint.setLocation( event.getX() + rectOffset.x, event.getY() + rectOffset.y );
				int mouseDeltaX = mouseMovePoint.x - mouseStartPoint.x;
				int mouseDeltaY = mouseMovePoint.y - mouseStartPoint.y;
				if(isResizing == false) {
					rectangleMove.setLocation(rectangle.x + mouseDeltaX, rectangle.y + mouseDeltaY );
				} else {
					rectangleMove.setSize(rectangle.width + mouseDeltaX, rectangle.height + mouseDeltaY );
				}
			}
			break;
	}
}
 
Example 11
Source File: DMXEditor.java    From haxademic with MIT License 5 votes vote down vote up
public void checkMouseDragPoint(MouseEvent event) {
	boolean createDragMode = P.store.getBoolean(DRAG_CREATE_MODE);
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		if(createDragMode && isHoveringPoint() == false) {
			// check points to see if one is hovered. cancel if so
			points.add(newPoint());
			draggingNewPoint = true;
		}
		break;
	case MouseEvent.RELEASE:
		// create a 2nd point on release
		if(createDragMode && draggingNewPoint) {
			points.add(newPoint());
			draggingNewPoint = false;
			lights.add(new LightBar(dmxUniverseDefault, dmxMode, points.get(points.size() - 2).position(), points.get(points.size() - 1).position())); // add last 2 points PVectors to new LightFixture
		}
		break;
	case MouseEvent.MOVE:
		// set hovered point as active
		boolean foundOne = false;
		for (int i = 0; i < points.size(); i++) {
			if(points.get(i).isHovered()) {
				pointIndex = i;
				foundOne = true;
			}
		}
		if(foundOne == false) pointIndex = -1;
		setActivePoint();
		break;
	case MouseEvent.DRAG:
		// if creating a new line, draw line from first point
		break;
	}
}
 
Example 12
Source File: UITextInput.java    From haxademic with MIT License 5 votes vote down vote up
public void mouseEvent(MouseEvent event) {
	if(active == false) return;
	int mouseX = event.getX();
	int mouseY = event.getY();
	
	switch (event.getAction()) {
	case MouseEvent.PRESS:
		pressed = rect.contains(mouseX,  mouseY);
		// if no textinputs are clicked, clear out ACTIVE_INPUT
		break;
	case MouseEvent.RELEASE:
		pressed = false;
		focused = rect.contains(mouseX, mouseY);
		ACTIVE_INPUT = null;
		if(focused) {
			SystemUtil.setTimeout(activeTimeout, 10);
		} else {
			if(saves) PrefToText.setValue(id, value);
		}
		break;
	case MouseEvent.MOVE:
		over = rect.contains(mouseX,  mouseY);
		break;
	case MouseEvent.DRAG:
		break;
	}
}