ControlListener (Javadocs: controlP5)

controlP5

## Interface ControlListener

- All Known Implementing Classes:
    Accordion, Background, CheckBox, ColorPicker, ControlGroup, ControllerGroup, DropdownList, Group, ListBox, MultiList, Radio, RadioButton, ScrollableList, Tab, Textarea

      public interface ControlListener

  ControlListener is an interface that can be implemented by a custom class to be notified when controller values change. To add a ControlListener to a controller use Controller.addListner()
  See Also:
    `Controller.addListener(ControlListener)`, `CallbackListener`
  +Example
    `

        /**
         * ControlP5 Listener.
         * the ControlListener interface can be used to implement a custom
         * ControlListener which listens for incoming ControlEvent from specific
         * controller(s). MyControlListener in the example below listens to
         * ControlEvents coming in from controller 'mySlider'.
         *
         * by andreas schlegel, 2012
         */
        import controlP5.*;

        ControlP5 cp5;
        MyControlListener myListener;

        void setup() {
          size(700,400);

          cp5 = new ControlP5(this);
          cp5.setColor(ControlP5.THEME_RED);

          cp5.addSlider("mySlider")
             .setRange(100,200)
             .setValue(140)
             .setPosition(200,200)
             .setSize(200,20);

          myListener = new MyControlListener();

          cp5.getController("mySlider").addListener(myListener);
        }

        void draw() {
          background(myListener.col);
        }

        class MyControlListener implements ControlListener {
          int col;
          public void controlEvent(ControlEvent theEvent) {
            println("i got an event from mySlider, " +
                    "changing background color to "+
                    theEvent.getController().getValue());
            col = (int)theEvent.getController().getValue();
          }

        }

    `

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `controlEvent(ControlEvent theEvent)` controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes.

- - ### Method Detail

    - #### controlEvent

          void controlEvent(ControlEvent theEvent)

      controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes. Use the CallbackListener to get informed when actions such as pressed, release, drag, etc are performed.
      Parameters:
        `theEvent` - ControlEvent
      See Also:
        `CallbackListener`, `CallbackEvent`

processing library controlP5 by Andreas Schlegel. (c) 2006-2015