The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
2.1KB

  1. /**
  2. @page getting_control_button_events Getting control button events
  3. Control button events are communicated from Lightpad and Control Blocks to your application via ControlButton objects.
  4. You can obtain an array of %ControlButton pointers associated with a specific Lightpad or Control %Block from its corresponding Block object using the Block::getButtons method---see the @ref discovering_blocks page for an example of how to obtain %Block objects.
  5. Each pointer to a %ControlButton will be valid for the lifetime of the %Block object.
  6. Once you have a %ControlButton you must register as a ControlButton::Listener to receive button pressed and button released callbacks.
  7. The process for doing this is to have one of your application's classes inherit from %ControlButton::Listener and override the pure virtual methods ControlButton::Listener::buttonPressed and ControlButton::Listener::buttonReleased.
  8. Then, when you register your derived class as a listener to a particular %ControlButton, your overriden methods will be called when the corresponding button is pressed and released.
  9. Registering a class derived from %ControlButton::Listener with multiple %ControlButton objects is done as follows:
  10. @code{.cpp}
  11. class ControlButtonListenerExample : public ControlButton::Listener
  12. {
  13. public:
  14. ControlButtonListenerExample (Block& block)
  15. {
  16. for (auto button : block->getButtons())
  17. button->addListener (this);
  18. }
  19. virtual void buttonPressed (ControlButton&, sourceControlButton, Block::Timestamp timestamp) override
  20. {
  21. // Do something when the sourceControlButton is pressed!
  22. }
  23. virtual void buttonReleased (ControlButton&, sourceControlButton, Block::Timestamp timestamp) override
  24. {
  25. // Do something when the sourceControlButton is released!
  26. }
  27. };
  28. @endcode
  29. When your overriden <code>buttonPressed</code> or <code>buttonReleased</code> methods are called you have access to two paramters: a reference to the %ControlButton that generated this event and timestamp for the event.
  30. You will find multiple examples of control button listeners in the @ref example_applications pages.
  31. */