We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hello hello. I'm building a small program for my thesis. It includes several buttons and i want those buttons, when clicked, to open a new sketch. Is that possible or is it done in some other way?
I'm familiar with Java but if it's done differently in Processing, i would like to know. Also i failed in search of this on forums and google, so i'm hoping for some direction if the question or topic already exists. Thank you
All the examples i found include only visual changes when button clicked, for example:
if(button.clicked)background(#somecolor);
I was hoping it would be that simple with invoking another sketch. thank you
Answers
You're looking for function runSketch(), in which we pass a String[] + a PApplet subclass instance in order to get another window running concurrently w/ other windows.
https://forum.Processing.org/two/discussions/tagged?Tag=papplet.runsketch()
https://forum.Processing.org/two/discussions/tagged?Tag=#multiplewindows
Too much info, i'm looking at everything and wondering what now..
I've found this example but i don't quite understand it.
https://forum.processing.org/one/topic/loading-other-sketches-from-within-a-sketch.html
This guy PhiLho says it would be best to merge all sketches. According to his examples (which you can find in his post ^^), does it mean i have to put all my code of each sketch in a separate class and then do as he did, extend them from main sketch class? Do I do it all in a completely new sketch? I'm totally confused with this one.
ok, different options:
processBuilder
when you have the sketches compiled as a exe-files they are just programs.
You could run them
via processBuilder
https://forum.processing.org/two/discussion/comment/73515/#Comment_73515
join the sketches
then you can join the sketches on processing programming level into one.
let's say you have those 2 simple sketches:
AND
only examples!!!
joining them you need one draw to handle what's going on. Therefore the draws above to draw1 and draw2.
Then join global vars and setup()
Don't have double names of vars etc. ;-)
The states tell you which sketch of the 2 old ones you are using.
ok, one idea is that:
these lines you could call from mousePressed on a button I think:
PM me if you need more
Best, Chrisir ;-)
I'm in big rush, will let you know the end of it ;) Thank you for your answers and help!!
All right
The launch() method might be your solution
That seems fairly easy and what i need quark, i put the right path but only the println line works, it doesn't open the app. I exported it before too.
This would be perfect if i could make it work.