We are about to switch to a new forum software. Until then we have removed the registration on this forum.
With the following code i have 2 windows. The default one get's fullscreen and the other one get's not. But for me it would be a lot easier if it would be the other way around. Is that possible? I tried some things but none of them worked.
import java.awt.Frame;
// run with command + r !!!
boolean sketchFullScreen = true;
// ----------------------------
PFrame f;
SecondApplet s;
void setup() {
size(displayWidth, displayHeight);
PFrame f = new PFrame(100, 100, 800, 600);
}
void draw() {
background(255, 0, 0);
fill(255);
rect(10, 10, frameCount, 10);
/*
s.background(0, 0, 255);
s.fill(100);
s.rect(10, 20, frameCount, 10);
s.redraw();
*/
s.redraw();
}
public boolean sketchFullScreen() {
return sketchFullScreen;
}
// . . . . . . . . . . . . . . . . . . .
public void mousePressed() {
println("mousePressed window 1");
}
// . . . . . . . . . . . . . . . . . . .
public void mouseMoved() {
println("mouseMoved window 1");
}
// . . . . . . . . . . . . . . . . . . .
public class PFrame extends Frame {
public PFrame(int x, int y, int width, int height) {
setBounds(x, y, width, height);
s = new SecondApplet();
add(s);
s.init();
show();
}
}
// . . . . . . . . . . . . . . . . . . .
public class SecondApplet extends PApplet {
public void setup() {
//size(400, 300);
//println(displayWidth);
size(displayWidth, displayHeight);
noLoop();
}
public void draw() {
background(0, 0, 255);
fill(100);
rect(10, 20, frameCount, 10);
redraw();
}
public void mousePressed() {
println("mousePressed window 2");
}
public void mouseMoved() {
println("mouseMoved window 2");
}
}
Answers
My experiment w/ 3 PApplet instances:
I only see 2 applets instead of 3. Anyway thanks, i saw the code when you posted 2 and i already was trying stuff with that. Your way of having multiple windows is so much easier to work with!
O yeah, why do you have the delay? I have the same result without the delay (only faster).
And how does your repositionCanvas work? Isn't there a change frame.getX() actually is 0 and therefor it hangs in a loop? and the >> ?
I have a small monitor, and a big monitor which is my main one. I want fullscreen on the small one. This is really hard :( Specially since it's not possible to toggle fullscreen (that would be so handy).
In preferences there is this option:
I figured it get's ignored as soon as you use:
So my guess is that it needs to be parsed on which window it should run.
I found some code for it in here: https://github.com/processing/processing/blob/416f2e5b99f38f0c350e0f2bc4e39563cb5dbbaa/app/src/processing/app/Preferences.java
But that's only for the preferences window. I have to sleep asap. Just dropping what i know so far in case someone can complete me.
That code is my testbed in researching how sketches are instantiated & initialized internally. :-B
You can peruse it by yourself too:
https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java
Static field instantiationDelay is just a experiment and a way to be aware when each PApplet is created!
Just comment out lines #26 and/or #33, so instantiationDelay keeps its initial 0 value or delay() never happens! :ar!
Inside setup(), both getX() & getY() are 0. Function repositionCanvas() is invoked as a separate thread("").
And awaits till Processing setLocation() by itself, hopefully setting both getX() & getY() to another non-0 coordinates!
Of course, when (id == 1), which is the fullscreen PApplet, repositionCanvas() isn't called at all! :-j
But then you've given me another idea. Method getX() isn't safe. Instead, method isVisible() is much more logic! :-bd
It's the bitwise right-shift operator -> processing.org/reference/rightshift.html
The effect of
>> 1
is the same as/2
for whole values! :bzTheoretically, since append() is used on args, no previous entries are lost:
http://processing.org/reference/append_.html
However, I dunno how to make passed arguments at command line to work at all.
I've tried out "--location=100,300", which corresponds to constant field ARGS_LOCATION, but it got ignored! :o3
That's why I've made my own repositionCanvas() function! :-w
Theoretically, "--display=1", which corresponds to ARGS_DISPLAY, passed argument would work.
But in my Processing v2.0.2, that is ignored as well! Try it out for yourself. Who knows?
Thanks, The bitshift /2 is cool to know, i only used it for getting colors.
I looked in the arguments yesterday as well. http://forum.processing.org/two/discussion/4140/use-displayn-command#Item_1 I have the same problem.
Around line 10534 is where ARGS_DISPLAY get handled but i'm still looking for a way to get into it. I will give an update later. https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java
Do you use mac or windows? (i'm on a mac 10.9.2).
And why do you use Processing v.2.0.2?
Processing 2.0.2, Lubuntu 13.04, 64-bit OpenJDK 7.u51, GeForce 9800GT.