Loading...
Logo
Processing Forum
Hello,

I have noticed when I make a GPanel invisible it is still possible to click on buttons and combo boxes.  When hovering over the location where the GPanel was last visible, the cursor icon will change from an arrow to a hand...

For now, I've simply changed their x,y location to be off the screen when invisible, but it would be nice if it wasn't necessary.

I'm using Processing 1.5.1 on Windows 7 with Java 1.6.0_27, and G4P version 1.7.6.

Anyone else seeing this?

cheers...bbc

Replies(5)

If you have a GPanel called pnlControlPanel you can disable ALL the controls on it with,

pnlControlPanel.setEnabled(false);

then renable them all with

pnlControlPanel.setEnabled(true);


Sorry, I overlooked that.  It works.  
Thanks!
The disabling of the panel didn't work for me because when the panel is folded up and disabled it cannot receive the click to expand it again (because its disabled). Instead I used the following code to enable and disable the buttons in the panel when it was expanded or folded up. Hope this is helpful.

Copy code

  1. void panel1_Click1(GPanel panel) { //_CODE_:panel1:628378:
  2.   if ( panel1.getEventType() == GTextField.EXPANDED){
  3.     println("Expansion!");
  4.     for(int h = 1; h < 7; h++){    //cycle through buttons and enable them when panel expanded
  5.     btnsA[h].setEnabled(true);
  6.     }
  7.   }else{
  8.     for(int h = 1; h < 7; h++){  //cycle through buttons and disable them if panel folded up
  9.     btnsA[h].setEnabled(false);
  10.   }
  11.   }
  12.   println("panel1 - GPanel event occured " + System.currentTimeMillis()%10000000 );
  13. } //_CODE_:panel1:628378:

Thanks for that information.

I will look at providing a solution in the next release.


Actually, I have found a flaw in the above workaround. If the panel is expanded but dragged, this triggers a panel event which is not an EXPANDED and that triggers the disable route. The following modification works:

if (( panel1.getEventType() == GTextField.EXPANDED) || ( panel1.getEventType() == GTextField.DRAGGED)){

but the routine probably should to disable only when the panel is folded up so as to allow the buttons to be enabled when other panel events are triggered.