G4P GUI Builder 4.2.1: new window KEEP_OPEN doesn't work

@quark, I really appreciate your G4P library and this is just a small issue I may have found in GUI Builder 4.2.1. on Windows.

When I set up a new window in G4P GUI Builder, selecting the KEEP_OPEN parameter for Action on close will not take effect and the new window can be closed.

Here’s a simple autogenerated code:

// Need G4P library
import g4p_controls.*;

public void setup(){
  size(480, 320, JAVA2D);
  createGUI();
  customGUI();
  // Place your setup code here  
}

public void draw(){
  background(230); 
}

// Use this method to add additional statements
// to customise the GUI controls
public void customGUI(){
}

synchronized public void win_draw1(PApplet appc, GWinData data) { //_CODE_:window1:799050:
  appc.background(230);
} //_CODE_:window1:799050:

// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setCursor(ARROW);
  surface.setTitle("Sketch Window");
  window1 = GWindow.getWindow(this, "Window title", 0, 0, 240, 120, JAVA2D);
  window1.noLoop();
  window1.addDrawHandler(this, "win_draw1");
  window1.loop();
}

// Variable declarations 
// autogenerated do not edit
GWindow window1;
1 Like

This is a bug in GUI Builder in that it doesn’t add the instruction to keep the window open. A simple fix would be to add the missing instruction in customGUI like this

public void customGUI() {
  window1.setActionOnClose(G4P.KEEP_OPEN);
}

Thanks for reporting it, please raise a ticket on Sourceforge

1 Like

Thanks Peter, I’ve opened a ticket on Sourceforge.

1 Like