artvl21 / controlp5

Automatically exported from code.google.com/p/controlp5
0 stars 0 forks source link

bringToFront() method does not completely change a Tab directly #86

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

/*
 * To reproduce the problem:
 * 1. Run sketch.
 * 2. Press Tab to go to extra tab (see the Button disappear).
 * 3. Click inside the Button area (which for this example is quite big ;-)
 * 4. Notice that the Button still works ONCE! It generates an event and changes the background color.
 */

import controlP5.*;
ControlP5 cp5;

int myColorBackground = 0;

void setup() {
  size(600, 600);
  noStroke();
  cp5 = new ControlP5(this);
  cp5.addTab("extra");     
  cp5.addButton("button")
    .setPosition(50, 50)
    .setSize(width-100, height-100)
    .getCaptionLabel().align(CENTER, CENTER);
}

void draw() {
  background(myColorBackground);
}

void button() {
  myColorBackground = 255 - myColorBackground;
  println("Button pressed! Setting background to: " + myColorBackground);
}

void keyPressed() {
  if (keyCode == TAB) {
    // PROBLEM: the bringToFront() method does not do everything needed to change a tab
    cp5.getTab("extra").bringToFront();
  }
}

What is the expected output? What do you see instead?
Expected is that the controllers from the old, invisible Tab no longer work. 
Instead they still work for one click.

What version of the product are you using? On what operating system?
ControlP5 2.0.4 on Processing 2.1 on Win8 x64.

Please provide any additional information below.
I'm using ControlP5 once again for a project (my biggest creative project to 
date!) and once again it's working great. This is just a minor issue that 
hopefully can be fixed in a future release.

Original issue reported on code.google.com by amnonp5@gmail.com on 30 Dec 2013 at 5:45