ControlP5 variable passing problem
in
Contributed Library Questions
•
2 years ago
Hello,
I am having troubles with the controlP5 lib. I want to write a class which contains my GUI. Creating a controlp5 object from within my own class works.
clicking a button should trigger the method controlEvent (ControlEvent theEvent). Now that i have rewritten the whole thing that it fits in the interfaceBuilder class, the method does not seem to be called anymore...
I am quite new to object oriented programming so an help in the right direction is greatly appreciated!!
my code:
- class InterfaceBuilder {
- //fields
- ControlP5 controlP5;
- Button b;
- //constructor
- InterfaceBuilder(PApplet applet) {
- controlP5 = new ControlP5(applet);
- controlP5.addButton("buttonB",255,100,120,80,19); //button name, theValue, xPos, yPos, width, heigth
- }
- // function buttonB will receive changes from
- // controller with name buttonB
- public void buttonB(int theValue) {
- println("a button event from buttonA: "+theValue);
- }
- //triggered when button is clicked
- public void controlEvent(ControlEvent theEvent) {
- println(theEvent.controller().name()); //prints name of the clicked button
- }
- }
I based my code on
http://www.sojamo.de/libraries/controlP5/examples/ControlP5button/ControlP5button.pde
The example works fine ....
I probably have a pointer error somewhere but i cannot figure it out!
greets jorrit
1