We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am attempting to utilize the saveCanvas() function to save the canvas as an image (duh).
function mouseClicked(){
saveCanvas(myCanvas, 'someImage', 'png');
}
However, when I click the mouse, the function seems to be called over and over again, flooding the window with dialogue boxes.
Please let me know if I am using this function wrong.
Thanks
Answers
I believe it's more stable to do that inside draw().
Just set apart some
boolean
variable in order to flag it's time to saveCanvas():@GoToLoop's workaround works - and suggests there's some kind of event handling conflict in saveCanvas(). You should report a bug
I don't think it's a bug but rather an annoying glitch. :-\"
AFAIK, saveCanvas() is modal. That is, it pops up a blocking window save dialog in the browser.
However, we end up clicking the mouse while dealing w/ that. Thus more MouseEvents occur! #-o
Thanks guys,
I'm an experienced C programmer, but still figuring out how the processing functions interact with each other.
true
, and postponing it to draw() to deal w/ it, we assure ourselves that only 1 happens for each draw() callback and the rest is discarded. *-:)@RobotProcess: Try it with mousePressed
That appears to work fine; though I'm slightly surprised there's such a big difference in behaviour...
@GoToLoop: the bug appears to be in mouseClicked. The documentation is a little too vague but at first glance the behaviour suggests that mouseClicked is firing events for as long as the mouse button is down; rather than waiting till the mouseDown/Up cycle is complete and then firing a single event :/
No - that's not it:
There must be some problematic interaction between saveCanvas and mouseClicked. Don't have time to dig any deeper right now..