Reputation: 2618
I understand that code inside Processing
's mouseDragged()
function will run if the mouse is moved and pressed at the same time. I was wondering how I could detect such movement through a variable since Processing
doesn't provide a corresponding variable for mouseDragged()
unlike mousePressed()
. Thanks!
Upvotes: 1
Views: 858
Reputation: 1
There is https://processing.org/reference/mouseMoved_.html which sounds like the right thing.
Upvotes: -1
Reputation: 2618
A solution specific to Processing
would be to create the variable that stores whether the user dragged the mouse or not. Under mouseDragged()
, the variable is set to true. Inside the draw()
function, if the mouse is not pressed, the variable is set to false.
Example:
boolean mouseDragged = false;
void draw()
{
if (mousePressed == false)
{
mouseDragged = false;
}
println(mouseDragged);
}
void mouseDragged()
{
mouseDragged = true;
}
Upvotes: 0
Reputation:
You need the MouseMotionListener
instead. It has two methods:
- Mousedragged
- MouseMoved
Upvotes: 4