ControlP5 events on invisible elements
in
Contributed Library Questions
•
1 years ago
hey, I'm working with controlp5 0.6.4 in processing 2.01a.
I have multiple tabs with loads of controls in them, and i'm switching between them using the TAB key.
whenever the mouse is positioned over a control, say a button, when switching to another tab, and then clicking anywhere the button will still receive the event.
also cp5.isMouseOver() permanently returns true after that, regardless where i move the mouse. which is too bad, cause I lock mouse events for the underlying sketch using isMouseOver().
any workarounds would be much appreciated.
here's some sample code:
try placing the cursor over the button, then pressing TAB to switch to the other tab. now click anywhere.
- import controlP5.*;
- ControlP5 cp5;
- public void setup() {
- cp5 = new ControlP5(this);
- cp5.addTab("second");
- Button b = cp5.addButton("buttonA", 0, 0, 30, 100, 70);
- }
- public void draw() {
- background(120);
- }
- public void keyPressed() {
- if (key == TAB) {
- if (cp5.window(this).currentTab().name().equals("default"))
- cp5.window(this).activateTab("second");
- else
- cp5.window(this).activateTab("default");
- }
- }
- public void mousePressed() {
- println(cp5.window(this).isMouseOver());
- }
- public void buttonA() {
- println("buttonA");
- }
1