Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created November 19, 2015 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/b87893bfd4e3e3d3758c to your computer and use it in GitHub Desktop.
Save atduskgreg/b87893bfd4e3e3d3758c to your computer and use it in GitHub Desktop.
PWindow w;
void setup() {
size(320, 240);
w = new PWindow(100, 100, 500, 200);
}
void draw() {
background(255, 0, 0);
fill(255);
rect(10, 10, frameCount, 10);
}
void mousePressed(){
println("mousePressed");
}
import processing.awt.*;
class PWindow extends PSurfaceAWT {
PWindowApp app;
PGraphics graphics;
int w;
int h;
PWindow(int x, int y, int w, int h) {
super( createGraphics(w,h) );
app = new PWindowApp();
app.setParent(this);
initFrame(app);
}
int getWidth(){
return w;
}
int getHeight(){
return h;
}
}
class PWindowApp extends PApplet {
PWindow parent;
void setParent(PWindow _parent){
parent = _parent;
}
void setup() {
size(parent.getWidth(), parent.getHeight());
background(0);
//noLoop();
}
void draw() {
println("PWindowApp.draw()");
}
// all mouse, keyboard events work in here as expected
// TODO: Could there be an API for defining these from the outside?
void mousePressed(){
println("second app mouse pressed");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment