However when I open a second window with G4P this only works in the main window, since keyPressed() is only called when a key is pressed and the main window is currently selscted.
What I want to do is prevent the user from accidentaly exiting the program by pressing the ESC-key in the second window. Is there a way?
Hi,
sorry it took a while to implement this, but now I can report: It works great.
Thank you.
For those who are curious, dispose(); works like this:
Set the “Action on Close” in the G4P Tool to “Close Window” to call the handler when the window is closed when [x] is pressed.
Link a method that will be called in the case of closing the window:
setup_window.addOnCloseHandler(this, "setup_windowClose"); // my window is called setup_window
This method will then be called:
public void setup_windowClose(GWindow gwin) { // needs a gwindow which represents the closed window
exit(); // I use exit here to also close the main window when the secondary is closed
println("closed secondary");
}