Picture: http://gyazo.com/e3bd39a4a967f4cd331f731fd6920702
The red cross on the picture represents the mouse position.
When I drag my box it keeps going grabbing the box in the upper left corner. How can I change this piece of code so that it will grab the box from the position where the mouse started to grab the box.
Here is my code: (GraphicsAlignment.settings = the point of the box) (Size of the grabable area 200x20)
if (Mouse.isDragging) {
Point pressed = Mouse.pressed;
if ((pressed.x > GraphicsAlignment.settings.x && pressed.x < GraphicsAlignment.settings.x + 200
&& pressed.y > GraphicsAlignment.settings.y && pressed.y < GraphicsAlignment.settings.y + 20)
|| isEnabled) {
GraphicsAlignment.settings.x = Mouse.dragged.x;
GraphicsAlignment.settings.y = Mouse.dragged.y;
Boot.getDisplayApplet().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
isEnabled = true;
} else {
Boot.getDisplayApplet().setCursor(Cursor.getDefaultCursor());
}
} else {
isEnabled = false;
Boot.getDisplayApplet().setCursor(Cursor.getDefaultCursor());
}