Help using onEnter, onLeave for TransparentWidgets

Hello!

I have a transparent widget where I’m rendering some rectangles. I’d like to set a flag whenever the mouse enters or leaves the bounding box of the widget. Is this possible? I tried…

struct AutobreakPatternReadout : TransparentWidget
{

  AutobreakPatternReadout()
  {
      box.size = Vec(DRAW_AREA_WIDTH, DRAW_AREA_HEIGHT);
  }

  void onEnter(const event::Enter &e) override
  {
      TransparentWidget::onEnter(e);
      this->module->pattern_lock = true;
      DEBUG("On enter called");
  }

  void onLeave(const event::Leave &e) override
  {
      TransparentWidget::onLeave(e);
      this->module->pattern_lock = false;
  }

  void step() override {
      TransparentWidget::step();
  }

However, I’m not seeing my debug string and my flag does not seem to be working. In the same widget, I’m handling mouse drag and mouse click events just fine. Thanks!

From the event::Enter docstring:

Must consume the Hover event to receive this event.

which would mean

	void onHover(const event::Hover& e) override {
		TransparentWidget::onHover(e);
		e.consume(this);
	}
2 Likes