Why "mouseButton=true" & "mousePressed=false"?
in
Programming Questions
•
1 years ago
Greetings Processing Forum,
I've been doing revision on Processing and was going through some of the chapters in the Processing Reference Book "...Programming Handbook for Visual Designers...". I was tinkering with some codes from the Chapter "Input 1: Mouse 1" and I tried to do some minor modification to one of the sketch examples. The example looks like this initially:
- void setup() {
- size (100, 100);
- noCursor();
- }
- void draw() {
- background(204);
- if (mousedPressed == true) {
- cursor();
- }
- }
I modified the codes to the following because I wanted the user to be able to revert the programme back to a state where no cursor is shown. However it only works if I use the "mouseButton" system variable instead of the "mousePressed" system variable. I don't see why mousePressed should not work and will greatly appreciate if you guys/girls can explain to me why this is so.
- void setup() {
- size(100, 100);
- noCursor();
- }
- void draw() {
- background(204);
- if (mousePressed == true) {
- if (mousePressed == LEFT) {
- cursor();
- } else if (mousePressed == RIGHT) {
- noCursor();
- }
- }
- }
1