sorry, i just want show a other example, where
@quark solved my 2 window question,
and based on this i added 2 slider where mouse wheel works,
incl separate event handlers.
hope you can use any of this.
// https://discourse.processing.org/t/mousewheel-on-g4p-window/8134
// https://discourse.processing.org/t/solved-g4p-options-in-second-window-problem/4552/3
import g4p_controls.*;
GOption option0, option1;
GOption woption0, woption1;
GCustomSlider sdr;
GCustomSlider wsdr;
GWindow[] window;
public void setup() {
size(200, 100);
createGUI();
createWindows();
}
public void draw() {
background(100, 100, 200);
}
public void createGUI() {
int posX = 40, posY =20, dposY = 20;
GToggleGroup tg = new GToggleGroup();
option0 = new GOption(this, posX, posY+0*dposY, 80, 24, "A");
option0.setTextAlign(null, GAlign.BOTTOM);
option1 = new GOption(this, posX, posY+1*dposY, 80, 24, "B");
option1.setTextAlign(null, GAlign.BOTTOM);
tg.addControls(option0, option1); // Group the option buttons
option1.setSelected(true); // Must set one of the options true
option0.addEventHandler(this, "option_clicked");
option1.addEventHandler(this, "option_clicked");
sdr = new GCustomSlider(this, 70, 50, 100, 50, null);
// show opaque ticks value limits
sdr.setShowDecor(false, true, true, true);
sdr.setNbrTicks(5);
sdr.setLimits(40, -100, 100);
sdr.addEventHandler(this, "sdr_moved");
}
public void option_clicked(GOption source, GEvent event) {
if (source == option0) {
println("option0");
} //option1.setSelected(false);
if (source == option1) {
println("option1");
} //option0.setSelected(false);
}
public void win_option_clicked(GOption source, GEvent event) {
if (source == woption0) {
println("woption0");
} //option1.setSelected(false);
if (source == woption1) {
println("woption1");
} //option0.setSelected(false);
}
//_______________________________________________________________________
public void createWindows() {
window = new GWindow[1];
// for (int i = 0; i < 1; i++) {
// window[i] = GWindow.getWindow(this, " ", 70+i*220, 160+i*50, 400, 400, JAVA2D);
// }
// menu window config
window[0] = GWindow.getWindow(this, "window2", 70, 160, 200, 100, JAVA2D);
window[0].setActionOnClose(G4P.CLOSE_WINDOW);
//window[0].addOnCloseHandler(this, "windowClosing");
//window[0].addData(new MyWinData());
window[0].addDrawHandler(this, "windowDraw");
//window[0].addMouseHandler(this, "windowMouse");
//window[0].addKeyHandler(this, "windowKey");
int posX = 40, posY =20, dposY = 20;
GToggleGroup wtg = new GToggleGroup();
woption0 = new GOption(window[0], posX, posY+0*dposY, 80, 24, "wA");
woption0.setTextAlign(null, GAlign.BOTTOM);
woption1 = new GOption(window[0], posX, posY+1*dposY, 80, 24, "wB");
woption1.setTextAlign(null, GAlign.BOTTOM);
wtg.addControls(woption0, woption1); // Group the option buttons
woption1.setSelected(true); // Must set one of the options true
woption0.addEventHandler(this, "win_option_clicked");
woption1.addEventHandler(this, "win_option_clicked");
wsdr = new GCustomSlider(window[0], 70, 50, 100, 50, null);
// show opaque ticks value limits
wsdr.setShowDecor(false, true, true, true);
wsdr.setNbrTicks(5);
wsdr.setLimits(40, -100, 100);
wsdr.addEventHandler(this, "wsdr_moved");
}
public void sdr_moved(GCustomSlider slider, GEvent event) {
if (slider == sdr) println("sdr integer value:" + slider.getValueI() + " float value:" + slider.getValueF());
}
public void wsdr_moved(GCustomSlider slider, GEvent event) {
if (slider == wsdr) println("wsdr integer value:" + slider.getValueI() + " float value:" + slider.getValueF());
}
//_______________________________________________________________________
synchronized public void windowDraw(PApplet appc, GWinData data) {
// MyWinData data2 = (MyWinData)data;
appc.background(200, 200, 0);
}
better help might come from quark.