I've been trying to make a box draggable, but I can't seem to get it right. Basically what I thought to do was check if the left mouse is held down, then check if the position of it is over the part I want dragged. Then it subtracts the new position of the mouse from the old position of the box, and adds that to the position of the box.
But it never works.
if((x > 2 + dragAmtX) && (x < 2 + width + dragAmtX) && (y > 60 + dragAmtY) && (y < 60 + height + dragAmtY))
dragAmtX = 2 - x;
dragAmtY = 60 - y;
//this is going to draw the box
drawBorderedRect(2 + dragAmtX, 60 + dragAmtY, 65 + dragAmtX, 72 + dragAmtY, 1, 0xFF3c3c3c, 0x80391BE0);