# Hiding ControlP5 controller

**URL:** <https://discourse.processing.org/t/hiding-controlp5-controller/1034>\
**Category:** Coding Questions\
**Created:** [June 17, 2018, 7:54pm UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034 "2018-06-17T19:54:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![deanomite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/deanomite/32/159_2.png) [@deanomite](https://discourse.processing.org/u/deanomite)\
**Post date:** [June 17, 2018, 7:54pm UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034/1 "2018-06-17T19:54:46Z")

</div>

Is it possible to hide a controlP5 say with a key press or boolean within a key press?

Am asking this because a controlP5 controller eg: slider, gets ‘created’ in setup() at the beginning and so there is no access to it later on, to control it via key presses or so it seems.

You can hide it as part of the creation process, but am not sure if it’s possible while a sketch is running.

Would anyone be kind enough to point me in the right direction? It’s more of a theory question at the moment… don’t have any specific code to share. Thanks!

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [June 18, 2018, 9:28pm UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034/2 "2018-06-18T21:28:39Z")

</div>

Try to use :

- `controlP5.Controller : Slider hide()`

- `controlP5.Controller : Slider show()`

```auto
import controlP5.*;

ControlP5 cp5;
float sliderValue = 0;

void setup() {
  size(700,400);
  cp5 = new ControlP5(this);
  
  // add a horizontal sliders, the value of this slider will be linked
  // to variable 'sliderValue' 
  cp5.addSlider("sliderValue")
     .setPosition(100,50)
     .setRange(0,255)
     ;
  
  cp5.hide();
}

void draw() {
  
}

void keyPressed(){
  cp5.show();
}

```

---

<div class="post-metadata">

**Author:** ![deanomite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/deanomite/32/159_2.png) [@deanomite](https://discourse.processing.org/u/deanomite)\
**Post date:** [June 19, 2018, 7:41am UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034/3 "2018-06-19T07:41:37Z")

</div>

Thanks Josephh… this worked perfectly. Was trying this out and was able to adapt to my code.

My mistake was that I was adding hide() to individual sliders/controllers rather than ‘cp5’ itself. Makes perfect sense. Thanks a ton for clearing that up! 🙂

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 20, 2018, 1:46pm UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034/4 "2018-06-20T13:46:01Z")

</div>

> [@deanomite](#):
>
> a controlP5 controller eg: slider, gets ‘created’ in setup() at the beginning and so there is no access to it later on

Just so you know – this isn’t true. For access, you can create a named controller object and then add it to your ControlP5 for direct access. Or (more commonly) you can use `getController()` to retrieve a named controller, then manipulate it – for example, calling show/hide.

From the ControllerBasics.pde demo sketch:

[http://www.sojamo.de/libraries/controlP5/examples/use/ControlP5basics/ControlP5basics.pde](http://www.sojamo.de/libraries/controlP5/examples/use/ControlP5basics/ControlP5basics.pde)

```java
  // change individual settings for a controller
  cp5.getController("numberboxA").setMax(255);
  cp5.getController("numberboxA").setMin(0);

```

---

<div class="post-metadata">

**Author:** ![deanomite](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/deanomite/32/159_2.png) [@deanomite](https://discourse.processing.org/u/deanomite)\
**Post date:** [June 21, 2018, 9:20pm UTC](https://discourse.processing.org/t/hiding-controlp5-controller/1034/5 "2018-06-21T21:20:51Z")

</div>

Thanks @jeremydouglass that’s very interesting! 🙂
