Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

setVisible(false) cause myButtons to stop working

$
0
0

Good aftenoon. First, sorry for my poor english !

I have an issue with my ControlP5 Buttons. I'm using a "Window" class, wich contains (among other stuff) an arrayList of Button. When i change the current window, I want to hide the previous buttons and show the buttons of the new window. Of course i'm using .setVisible(boolean), but apparently, doing so cause my "new" buttons to not work properly.

Here is the location in the code where I found the problem: for(i = 0; i < listeBoutons.size(); i++){ listeBoutons.get(i).setVisible(false); }

for(i = 0; i < fenetreActive.boutons.size(); i++){ fenetreActive.boutons.get(i).setVisible(true); }

"listeBoutons" is my ArrayList which contains ALL the Buttons of my application (I need this elsewhere). I'm lazzy, so I basically try to make all the buttons invisible THEN using fenetreActive (which is my "window") acces to the Buttons of the new windows and make them visible. It's a harsh way to proceed but seems to work : all my button have the correct .isVisible() state (i've check by printing some tracks with .getInfo() )

If I use JUST the second loop, as expected when I change the window, new buttons appears and the "old" stay on the screen. Every single one of them work PERFECTLY fine in that case. But, if i add the first loop, in charge of "removing" the old buttons from my screen... they do disapear... but the new ones are not functional. Weird thing is : the new buttons appear on screen (with correct text, size etc...) but won't react to any Event.

I'm a bit lost. My program is working as if, by hidding my Buttons, I had disabled them all.

Here is a sample of my controlEvent function :

void controlEvent(ControlEvent event){ println("Event received from" + event.getName()); if(event.getName().equals("Begin")){ changeWindow("Menus"); } else if(event.getName().equals("OtherName")){ println("something"); } //Etc... } }

I'm not used to work with ControlP5, so my understanding of the problem may be wronged. It would be great if someone could explain to me what the problem really is !


Viewing all articles
Browse latest Browse all 2896

Trending Articles