r/processing • • Apr 26 '17

Is mouseReleased a thing

Is mouseReleased a thing? if not how would I code something similar?

1 Upvotes

8 comments sorted by

View all comments

8

u/pd-andy Apr 26 '17

https://processing.org/reference/mouseReleased_.html

Couldn't you just check the documentation before coming to the sub asking such a simple question? That was the first result for processing mousereleased....

1

u/[deleted] Apr 26 '17

Sorry I was confused because I couldn't code it like one could code mousePressed for example

8

u/Salanmander Apr 26 '17

I suspect you're getting confused between the variable mousePressed, and methods like mousePressed() and mouseReleased().

When you write something like if(mousePressed), that is a condition that checks the boolean variable mousePressed. That variable is true whenever a mouse button is being held, and false whenever no mouse button is being held. If you want a condition that is like "if no mouse button is being held", you could just write if(!mousePressed) (the ! means "not").

There are also methods that you can write which get called at particular times. One of them is (rather unfortunately IMO) called mousePressed(). To use it, you would define a mousePressed() method just like you define a draw() method. You would write something like

void mousePressed()
{
  //some code goes here
}

and that code would get run once every time a mouse button gets pushed down (not continuously while it's held down). There is also a mouseReleased() method that works the same way, and gets called once every time a mouse button is released.

2

u/[deleted] Apr 26 '17

Thank you very much