# Having trouble hiding Controllers

**URL:** <https://discourse.processing.org/t/having-trouble-hiding-controllers/28282>\
**Category:** Libraries\
**Created:** [March 5, 2021, 12:16pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282 "2021-03-05T12:16:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bluebottle](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Bluebottle](https://discourse.processing.org/u/Bluebottle)\
**Post date:** [March 5, 2021, 12:16pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282/1 "2021-03-05T12:16:34Z")

</div>

I’ve been trying to have different knobs and buttons available depending on the tab pressed in the button bar at the top. Unfortunately, I haven’t been able to get this knob to hide using the button bar and am unsure as to why. Any help would be much appreciated! Thank you

import controlP5.\*;

ControlP5 cp5;

ButtonBar bar;  
Knob speedControl;

int speed;  
PFont font;

void setup(){  
size(1000, 1000);  
smooth();  
noStroke();

font = createFont(“Arial”, 32, true);

cp5 = new ControlP5(this);

speedControl = cp5.addKnob(“speedValue”)  
.setRange(0,255)  
.setValue(255)  
.setPosition(150,150)  
.setRadius(100)  
.setNumberOfTickMarks(1)  
.setTickMarkLength(8)  
.snapToTickMarks(false)  
.setColorForeground(color(100, 200, 50))  
.setColorBackground(color(50, 80, 20))  
.setColorActive(color(0,255,0))  
.setDragDirection(Knob.HORIZONTAL)  
.setCaptionLabel(“Speed Value”).setFont(font);

bar = cp5.addButtonBar(“bar”)  
.setPosition(0, 0)  
.setSize(1000, 50)  
.addItems(split(“a b”," "))  
.setColorForeground(color(100, 200, 50))  
.setColorBackground(color(50, 80, 20))  
.setColorActive(color(0,255,0))  
.setCaptionLabel(“Speed Value”).setFont(font);  
bar.changeItem(“a”,“text”,“Line Following”);  
bar.changeItem(“b”,“text”,“Free Control”);  
}

void draw(){  
}

void speedValue(int speedValue){  
speed = speedValue;  
println("Motor Speed: " + speed);  
}

void bar(int click) {  
if(click == 0){  
speedControl.hide();  
}  
if(click == 1){  
println(“Free Control”);  
speedControl.hide();  
}  
}

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 5, 2021, 11:45pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282/2 "2021-03-05T23:45:33Z")

</div>

use this

```auto
cp5.hide (); /// to hide

cp5.show ();//// to show

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 5, 2021, 11:58pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282/3 "2021-03-05T23:58:09Z")

</div>

chick your code

```auto
speedControl = cp5.addKnob("speedValue");

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 7, 2021, 10:24pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282/4 "2021-03-07T22:24:56Z")

</div>

Hello,

Please format your code as a courtesy to the community:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)  
You can go back and edit it.

I was able to hide\show the knob with these changes:

```auto
void draw() 
  {
  background(100);
  }

  if (click == 0) 
    {
    speedControl.hide();
    }
  
  if (click == 1) 
    {
    println("Free Control");
    speedControl.show();
    }

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [March 7, 2021, 10:27pm UTC](https://discourse.processing.org/t/having-trouble-hiding-controllers/28282/5 "2021-03-07T22:27:41Z")

</div>

@glv

nice to see you 😃 😃 😃 😃
