We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › mouse click persistent effect
Page Index Toggle Pages: 1
mouse click persistent effect (Read 629 times)
mouse click persistent effect
Mar 26th, 2010, 1:48pm
 
This question may have been asked elsewhere, but if so I have been unable to locate it.  My apologies in advance.  I am still new to Processing.

I want my users to click on a object and have that object toggle in size (expand or shrink) and then persist at that size until it is clicked again.  Currently the object only expands for an instant and then shrinks again.  I know mousePressed() is only called once, but there must (I assume) be a way to add this basic functionality to a Processing program.  Any thoughts or help would be most appreciated.
Re: mouse click persistent effect
Reply #1 - Mar 26th, 2010, 3:11pm
 
If it has only two states, large and small, just have a boolean global variable... and toggle it between true and false on mouseReleased.
Then when you draw it, draw it big or small depending on the value of the boolean variable.
Re: mouse click persistent effect
Reply #2 - Mar 26th, 2010, 3:14pm
 
Just solved my own problem.  I was thinking about it 100% the wrong way.  For those interested, create a boolean value in your object's subclass, toggle that value based on mousePressed, and then in your draw() method choose which way to display your object based on that boolean value.  
Re: mouse click persistent effect
Reply #3 - Mar 26th, 2010, 3:19pm
 
@Giles many thanks.  I didn't see your response until after I'd posted.
Page Index Toggle Pages: 1