G4P - Click on panel disables button

Hello!

I found that if i click on a not collapsible panel (without dragging) it disables buttons. Is that expected behaviour? If yes, can I change it?
Here is some code to exemplify what i mean:

main

import g4p_controls.*;

GPanel modul_2;
public void setup(){
  size(100, 100, JAVA2D);
  createGUI();
}

public void draw(){
}

gui

public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:570995:
  println("button1 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button1:570995:

public void panel1_Click1(GPanel source, GEvent event) { //_CODE_:panel1:957461:
  println("panel1 - GPanel >> GEvent." + event + " @ " + millis());
} //_CODE_:panel1:957461:

// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setMouseOverEnabled(false);
  surface.setTitle("Sketch Window");
  button1 = new GButton(this, 10, 10, 80, 30);
  button1.setText("Face text");
  button1.addEventHandler(this, "button1_click1");
  panel1 = new GPanel(this, 10, 50, 80, 40, "Tab bar text");
  panel1.setCollapsible(false);
  panel1.setText("Tab bar text");
  panel1.setOpaque(true);
  panel1.addEventHandler(this, "panel1_Click1");
}

// Variable declarations 
// autogenerated do not edit
GButton button1; 
GPanel panel1;

Additional Question: what is that autogenerated //CODE:… ? Can I access anything directly with it?

Great library by the way!

It appears to be a bug in G4P I will have to do some investigations.

The code inside the GUI tab is generated by GUI Builder when you move from the design window to the Processing IDE. This means that it will overwrite any code changes made by the user in the gui tab. The only exception is the code withing the event handlers e.g.

public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:570995:
  println("button1 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button1:570995:

Under no circumstances should you edit the code in line 1 and 3 because it will be overwritten by GUI Builder. The code in line 2 can be edited or replaced by one or more lines of source code and this will be remembered by GUI Builder when moving to the design window.

The actual comment //_CODE_:button1:570995: links the source code inside the event handler to the GUI control so if the user changes the method name for the event handler it will correctly recreate the event handler in the gui tab. It has no other purpose so cannot be used by the programmer.

Thanks for the unexpectedly fast answer!

No problem just happened to be around.

So I have done some investigating …
sherlock

and have found the bug.

I have a working solution and it will be included in the next release (4.3.7) which should be available in Processing early next week. :+1:

Thanks again for the fast reply! So I tried a bit more and found another strange behaviour. Probably it is the same bug. Whenever I use any of the elements within a panel (slider, option, button) it disables the elements outside of the panel. If I drag the panel around, the outside elements are enabled again. Here is the code:

main


import g4p_controls.*;

GPanel modul_2;
public void setup(){
  size(200, 200, JAVA2D);
  createGUI();
}

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

gui

public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:570995:
  println("button1 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button1:570995:

public void panel1_Click1(GPanel source, GEvent event) { //_CODE_:panel1:957461:
  println("panel1 - GPanel >> GEvent." + event + " @ " + millis());
} //_CODE_:panel1:957461:

public void slider1_change1(GSlider source, GEvent event) { //_CODE_:slider1:643990:
  println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
} //_CODE_:slider1:643990:

public void option1_clicked1(GOption source, GEvent event) { //_CODE_:option1:420023:
  println("option1 - GOption >> GEvent." + event + " @ " + millis());
} //_CODE_:option1:420023:

public void option2_clicked1(GOption source, GEvent event) { //_CODE_:option2:953345:
  println("option2 - GOption >> GEvent." + event + " @ " + millis());
} //_CODE_:option2:953345:

public void button2_click1(GButton source, GEvent event) { //_CODE_:button2:750552:
  println("button2 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button2:750552:

public void slider2_change1(GSlider source, GEvent event) { //_CODE_:slider2:558167:
  println("slider2 - GSlider >> GEvent." + event + " @ " + millis());
} //_CODE_:slider2:558167:

public void option3_clicked1(GOption source, GEvent event) { //_CODE_:option3:644481:
  println("option3 - GOption >> GEvent." + event + " @ " + millis());
} //_CODE_:option3:644481:

public void option4_clicked1(GOption source, GEvent event) { //_CODE_:option4:383928:
  println("option4 - GOption >> GEvent." + event + " @ " + millis());
} //_CODE_:option4:383928:

public void button3_click1(GButton source, GEvent event) { //_CODE_:button3:886551:
  println("button3 - GButton >> GEvent." + event + " @ " + millis());
} //_CODE_:button3:886551:



// Create all the GUI controls. 
// autogenerated do not edit
public void createGUI(){
  G4P.messagesEnabled(false);
  G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
  G4P.setMouseOverEnabled(false);
  surface.setTitle("Sketch Window");
  button1 = new GButton(this, 10, 10, 80, 30);
  button1.setText("B1");
  button1.addEventHandler(this, "button1_click1");
  panel1 = new GPanel(this, 10, 50, 90, 140, "Tab bar text");
  panel1.setCollapsible(false);
  panel1.setText("Tab bar text");
  panel1.setOpaque(true);
  panel1.addEventHandler(this, "panel1_Click1");
  slider1 = new GSlider(this, 40, 30, 100, 30, 10.0);
  slider1.setRotation(PI/2, GControlMode.CORNER);
  slider1.setLimits(0.5, 0.0, 1.0);
  slider1.setNumberFormat(G4P.DECIMAL, 2);
  slider1.setOpaque(false);
  slider1.addEventHandler(this, "slider1_change1");
  togGroup1 = new GToggleGroup();
  option1 = new GOption(this, 50, 80, 30, 20);
  option1.setIconAlign(GAlign.LEFT, GAlign.MIDDLE);
  option1.setText("1");
  option1.setOpaque(false);
  option1.addEventHandler(this, "option1_clicked1");
  option2 = new GOption(this, 50, 110, 30, 20);
  option2.setIconAlign(GAlign.LEFT, GAlign.MIDDLE);
  option2.setText("2");
  option2.setOpaque(false);
  option2.addEventHandler(this, "option2_clicked1");
  togGroup1.addControl(option1);
  option1.setSelected(true);
  panel1.addControl(option1);
  togGroup1.addControl(option2);
  panel1.addControl(option2);
  button2 = new GButton(this, 50, 30, 30, 30);
  button2.setText("B1");
  button2.addEventHandler(this, "button2_click1");
  panel1.addControl(slider1);
  panel1.addControl(button2);
  slider2 = new GSlider(this, 150, 80, 100, 30, 10.0);
  slider2.setRotation(PI/2, GControlMode.CORNER);
  slider2.setLimits(0.5, 0.0, 1.0);
  slider2.setNumberFormat(G4P.DECIMAL, 2);
  slider2.setOpaque(false);
  slider2.addEventHandler(this, "slider2_change1");
  togGroup2 = new GToggleGroup();
  option3 = new GOption(this, 160, 130, 30, 20);
  option3.setIconAlign(GAlign.LEFT, GAlign.MIDDLE);
  option3.setText("3");
  option3.setOpaque(false);
  option3.addEventHandler(this, "option3_clicked1");
  option4 = new GOption(this, 160, 160, 30, 20);
  option4.setIconAlign(GAlign.LEFT, GAlign.MIDDLE);
  option4.setText("4");
  option4.setOpaque(false);
  option4.addEventHandler(this, "option4_clicked1");
  togGroup2.addControl(option3);
  option3.setSelected(true);
  togGroup2.addControl(option4);
  button3 = new GButton(this, 160, 80, 30, 30);
  button3.setText("B3");
  button3.addEventHandler(this, "button3_click1");
}

// Variable declarations 
// autogenerated do not edit
GButton button1; 
GPanel panel1; 
GSlider slider1; 
GToggleGroup togGroup1; 
GOption option1; 
GOption option2; 
GButton button2; 
GSlider slider2; 
GToggleGroup togGroup2; 
GOption option3; 
GOption option4; 
GButton button3;

Yes it is down to the same bug :slight_smile:

What your sketch did was highlight another problem. If you change the value of the slider on the panel and then try the other slider, the panel moves as if its been dragged. It appears that the panel is not releasing focus correctly - anyway I have fixed that.

Just shows how difficult it is to avoid logical errors. Rather than issue a new release of G4P just for you to find another problem :grin: I can send you an updated library jar file which you can try and break for me. If interested send a PM with an email address I can attach the file.