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.

44 lines
1015B

  1. #pragma once
  2. #include "widget/Widget.hpp"
  3. namespace rack {
  4. namespace widget {
  5. /** A Widget that consumes recursing events but gives a chance for children to consume first.
  6. You can of course override the events.
  7. You may also call OpaqueWidget::on*() from the overridden method to continue recursing/consuming the event.
  8. */
  9. struct OpaqueWidget : Widget {
  10. void onHover(const HoverEvent &e) override {
  11. Widget::onHover(e);
  12. if (!e.getConsumed())
  13. e.consume(this);
  14. }
  15. void onButton(const ButtonEvent &e) override {
  16. Widget::onButton(e);
  17. if (!e.getConsumed())
  18. e.consume(this);
  19. }
  20. void onHoverKey(const HoverKeyEvent &e) override {
  21. Widget::onHoverKey(e);
  22. if (!e.getConsumed())
  23. e.consume(this);
  24. }
  25. void onHoverText(const HoverTextEvent &e) override {
  26. Widget::onHoverText(e);
  27. if (!e.getConsumed())
  28. e.consume(this);
  29. }
  30. void onDragHover(const DragHoverEvent &e) override {
  31. Widget::onDragHover(e);
  32. if (!e.getConsumed())
  33. e.consume(this);
  34. }
  35. };
  36. } // namespace widget
  37. } // namespace rack