Controlp5 show and hide
in
Contributed Library Questions
•
2 years ago
Hello. I am building a "dynamic"-interface in controlp5 and i am having some trouble. i need a function that can show and hide buttons. normally that shouldn't be a big problem but anyhow i .show() the button after .hide() i am not albe to .hide() again - no matter if the boolean display is false or true....
a little code example. try it out... i need help.
- import controlP5.*;
- ControlP5 controlP5;
- controlP5.Button b;
- boolean display = false;
- void setup() {
- size(640, 480);
- controlP5 = new ControlP5(this);
- b = controlP5.addButton("buttonA", 0, 100, 100, 80, 19);
- b.setSwitch(true);
- }
- void draw() {
- hideButton();
- }
- void hideButton() {
- if (display == false) {
- b.hide();
- }
- else {
- b.show();
- }
- }
- void keyPressed() {
- if (key == 'a') {
- display = false;
- }
- if (key == 's') {
- display = true;
- }
- }
1