We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. I have a project wich runs in two windows. One is intended to control the other. So, in the first one I'm drawing CP5 controls. But I'n not being able to handle the events in the second window. I mean, I don't know how to capture events in a second window.
Default code would be: cp5.addToggle("toggleValue")
Well, that tries to resolve the event in the same window.
I can see you can pass a misterious object as first param, so I tried things like: cp5.addToggle(secondWindow, "toggleValue")
But that wont work either. The error is always this: Exception in thread "Thread-2" java.lang.NullPointerException
I think is previous versions one could create windows using controlWindow. Not sure. I'm using processing 3. And I'm creating the windows myself (in Eclipse context)
So, any clue on how to define a event listener or something like that?
Thanks in advance.
Answers
The method I was looking for seems to be .plugTo()
Still working on this. I think I managed to make it work. Each PApplet window must declare it's own ControlP5 instance. And the, one creates the controller and renders it in the other window. Cool. However, now there's an error related to P2D renderer. It crashes with something like:
"cannot run the OpenGL renderer outside the main thread".
If I try using the default renderer, the screen flashes.
By the way, this official code won't work with Processin 3.0: http://www.sojamo.de/libraries/controlP5/examples/extra/ControlP5frame/ControlP5frame.pde Error is: the method add(Component) in the type Container is not applicable for the arguments (ControlFrame).
And I searched the forum, and found info like this, but at a first glance it is chinese for me: https://forum.processing.org/two/discussion/7202/controlp5-controlwindow-and-controlp5frame
So, I'd be happy if I found a way to use P2D renderer again. Any clue?
In my experiments w/ multiple PApplet windows, I was only able to have 1 of them use an OpenGL renderer. All the others had to stick w/ JAVA2D renderer. :(
Oh, well, good to know. I can manage, but I need to know something unrelated to this. Why the first PApplet under Eclipse opens in fullscreen mode? I don't mean the fullscreen that we can control with processing, but the java window itself. I mean, it's fullscreen while my sketch occupies just 800x600 of the screen. If I can solve that, I don't need a second P2D PApplet :)
Never used Eclipse yet. Sorry... 8-|
@gperez the ControlFrame example hasn't been updated yet. There is discussion about the Component error here. Just in case, a working example using the P3D and P2D renderer with 2 windows:
and here an example for an eclipse project to open a processing sketch (non-fullscreen, window only), also see this thread: