Handling dragging

Alas, with a new input system comes a need for drag handling. I have 3 abstract methods that implementations use to handle parsed dragging.

My problem is getting the drag from raw mouse input.

How I calculate drag delta. startx and starty are the last known coordinates of the mouse

public int getDX(int x, int y) {
		Point mouse = new Point(x, y);
		int dx = mouse.x - startx;
		if (!Mouse.isButtonDown(0)) {
			return 0;
		} else {
			if (wasDown) {
				// Continue
			} else {
				wasDown = true;
				return 0;
			}
		}
		startx = mouse.x;
		return dx;
	}
	public int getDY(int x, int y) {
		Point mouse = new Point(x, y);
		int dy = mouse.y - starty;
		if (!Mouse.isButtonDown(0)) {
			return 0;
		} else {
			if (wasDown) {
				// Continue
			} else {
				wasDown = true;
				return 0;
			}
		}
		starty = mouse.y;
		return dy;
	}

This is where mouse input is forwarded. And yes, Y values have already been adjusted to go with the coordinate orientation

public void mouse(int x, int y, boolean down) {
		int dx = getDX(x, y);
		int dy = getDY(x, y);
		if (dy > 0 || dx > 0) drag(dx, dy);
		if (wasDown) {
			if (!down) {
				endDrag();
				wasDown = false;
			}
		} else {
			if (down) {
				startDrag(x, y);
				wasDown = true;
			}
		}
	}

Any thoughts on why the drag isn’t being handled would be much appreciated :slight_smile:

CopyableCougar4