We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello I am looking for the best way how to create a new window in processing. I search for many solution and I find using g4p. I tried a little code to find out how does it work but I don't know what I am doing wrong. Later I would like to make 2 windows. In one sliders on the other changing graphic. But for now it seems I cant handle the first window. in this code the cursor should change on rect but it just blinking or doing nothing.
import g4p_controls.*;
GWindow Screen;
void setup() {
size(400, 320, P2D);
Screen = GWindow.getWindow(this, "Fullscreen", 100, 50, 480, 320, P2D);
}
void draw() {
background(230);
rectMode(CENTER);
rect(100, 100, 100, 100);
if (dist(100, 100, mouseX, mouseY) < 50) {
cursor(HAND);
} else {
cursor(ARROW);
}
Screen.addDrawHandler(this, "windowDraw");
}
public void windowDraw(PApplet app, GWinData data) {
app.background(255);
app.strokeWeight(2);
app.stroke(0);
app.line(app.width / 2, app.height/2, app.mouseX, app.mouseY);
}
Answers
I have correctly formatted your original post so we can see the code. The single apostrophe is for single line or in-line code, for multiple lines of code it should be indented by 4 paces. Check this post to find out how to format your code.
The G4P library takes control over cursor image so it can change it when the mouse passes over a control such as a slider, which explains why you can't change it.
In your code there is a mistake, line 18 should be in the setup method like this.
If you want to create GUIs with G4P then I strongly recommend that you install the G4P GUI Builder tool from the Tools menu. This tool is a visual GUI designer tool for G4P. My website has a number of video guides showing how to use it.