We are about to switch to a new forum software. Until then we have removed the registration on this forum.
when executing a saveFrame command on a graphics-type application, the Controlp5 sliders I've set up get saved in the png image file. I can't seem to get the sliders to disappear on a keyPressed() function - ie. i want to press the 'x' key to have the sliders turn invisible - yet the line of code I'm using
cp5.get("nameofslider").hide();
works in the draw() function (outside of the keyPressed() routine so I know the command works - it just doesn't work where it should). Code pasting worked and is shown below - hoping for anyone that has tried the same thing to please wise me up to what needs to happen. Thank you in advance.
btw - the keyPressed routine that I'm needing to run the above hide command works fine for the saveFrame command so I know that's programmed correctly.
Answers
set a flag in keyPressed, act on the flag in draw.
@koogs - thanks for the help. In the below example, I can save the canvas (saveFrame), yet the line of code that is meant to make the slider disappear doesn't work. cp5.get("Darks1X").hide(); works fine on its own - just can't seem to trigger it to work in the function. Leaving one slider on the screen for a test comparison. Any ideas please?
OK - still at sea - I duplicated my canvas drawing to a graphics buffer and found that the slider WAS being disabled but this didn't show as the canvas needed to be refreshed somehow to show this. I thought I could just save the buffer after loading it into the canvas, but this doesn't work. Here's the save drawing bit of the code where the slider disappears, the buffer must be empty as nothing appears onto the black background - just a disappearing slider.