Just drag the mouse around, and the rectangle will follow!
Much less code. Thanks to @N8WM for concept.