Move an object using mouseDragged

for example, I drew a rectangle on the screen using the ofDrawRectangle function. Then how do I use mouseDragged function to move this rectangle around using my mouse?

This should work:

ofDrawRectangle(ofGetMouseX(), ofGetMouseY(), 50, 50);