# CP5 – "global" tab overrides bringToFront()

**URL:** https://discourse.processing.org/t/cp5-global-tab-overrides-bringtofront/33617
**Category:** Libraries
**Created:** [November 19, 2021, 2:16pm UTC](https://discourse.processing.org/t/cp5-global-tab-overrides-bringtofront/33617 "2021-11-19T14:16:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jango\_fx](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jango_fx/32/15051_2.png) [@jango\_fx](https://discourse.processing.org/u/jango_fx)
#### Post date: [November 19, 2021, 2:16pm UTC](https://discourse.processing.org/t/cp5-global-tab-overrides-bringtofront/33617/1 "2021-11-19T14:16:34Z")

</div>

i’d like to use controlP5’s Tabs.  
and i’d like to have some GUI elements showing up in all tabs (that is exist on the “global” tab)  
but i DON’T want those elements to overlay everything else.  
i thought `bringToFront()` would be the appropriate method. but it seems the “global” tab stays in front of everything else, no matter what… ☹

is any there anything else i can do, to manipulate the “z-index” of controlP5 elements?

```auto
import controlP5.*;

ControlP5 cp5;
ScrollableList dropdown1, dropdown2;

void setup() {
  size(300, 400);
  cp5 = new ControlP5(this);
  cp5.addTab("extra").activateEvent(true);

  dropdown2 = cp5.addScrollableList("dropdown2")
    .setPosition(100, 105)
    .setColorBackground(color(60));
  ;
  dropdown1 = cp5.addScrollableList("dropdown1")
    .setPosition(50, 50)
    ;

  for (int i=0; i<40; i++) {
    dropdown1.addItem("thing "+i, i);
    dropdown2.addItem("item "+i, i);
  }

  cp5.getController("dropdown2").moveTo("global");
  cp5.getController("dropdown1").moveTo("extra");
  cp5.getController("dropdown1").bringToFront();
  cp5.getTab("extra").bringToFront();
}

void draw() {
  background(0);
  if (dropdown1.isMouseOver()) {
    println(frameCount + " go to front");
    dropdown1.bringToFront();
  }
}

void controlEvent(ControlEvent theControlEvent) {
  if (theControlEvent.isTab()) {
    if (theControlEvent.getTab().getName() == "extra")
    {
      println("bring to front");
      dropdown1.bringToFront();
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [November 19, 2021, 2:51pm UTC](https://discourse.processing.org/t/cp5-global-tab-overrides-bringtofront/33617/2 "2021-11-19T14:51:54Z")

</div>

> [@jango\_fx](#):
>
> `if (theControlEvent.getTab().getName() == "extra")`

`if ("extra".equals(theControlEvent.getTab().getName())) {`

> **[equals() / Reference](https://processing.org/reference/String_equals_.html)**
>
> Compares two strings to see if they are the same. This method is necessary because it's not possible to compare strings using the equality operator (==). Returns true if the strings are the sam…

---

<div class="post-metadata">

### Author: ![jango\_fx](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jango_fx/32/15051_2.png) [@jango\_fx](https://discourse.processing.org/u/jango_fx)
#### Post date: [November 19, 2021, 11:55pm UTC](https://discourse.processing.org/t/cp5-global-tab-overrides-bringtofront/33617/3 "2021-11-19T23:55:55Z")

</div>

thx, but doesn’t make a difference
