I'm iteratively optimizing code for a project I'm working on which also uses controlP5. I wanted to move several color-related Sliders into two ColorPickers. I need to get an event when the colors are changed. In the currect code I'm monitoring the controlEvents for all the individual Sliders. It seems - unlike all the other ControlGroup subclasses - ColorPicker doesn't send out controlEvents. Perhaps I'm misinterpreting the method name but activateEvent() seems to have no effect on the sending of events. Setting it to true doesn't generate events for a ColorPicker. Setting it to false doesn't prevent events for all the other ControlGroup subclasses.
So my main question is: how can I receive controlEvents from the ColorPicker?
Code Example
So my main question is: how can I receive controlEvents from the ColorPicker?
Code Example
- import controlP5.*;
- ControlP5 cp5;
- ColorPicker cp;
- void setup() {
- size(400,400);
- noStroke();
- cp5 = new ControlP5(this);
- cp = cp5.addColorPicker("picker")
- .setPosition(60,100)
- .setColorValue(color(25,85,145,255))
- .activateEvent(true)
- ;
- }
- void draw() {
- background(cp.getColorValue());
- fill(0,80);
- rect(50,90,275,80);
- }
- void controlEvent(ControlEvent theEvent) {
- // ColorPicker is of type ControlGroup but there are no events coming in
- if (theEvent.isGroup()) {
- println("event from group " + theEvent.getGroup());
- }
- }
1