How to use the mouseDragged event?

Very very new to coding here, just a little bit confused on how to use the ofApp::mouseDragged() function. I want to make something that draws a bunch of circles along the users dragged path, similar to a paintbrush, but I don’t know how to use the dragged function at all. Is it like an if statement? is it similar to update? Any help is greatly appreciated

Hi,

I always find it easy, when I am not sure exactly what a function does, to test it with printing output to the console.

For example here you could use this

void ofApp::mouseDragged(int x, int y, int button){

	cout << "test   " << x << " , " << y << endl;
}

To see that when you click and hold the mouse the function will constantly fire (like the update function), but only when the button is pressed. The x and y values will refer to the position of the mouse in the viewport.

1 Like

ah that makes it much clearer. Thank you very much!