Handling Mouse Directly. GUI framework documentation

I wrote a couple of prototype modules in Rack 0.6 where I wanted to get Mouse events directly.

I had a method

  void SlowSliderWidget::onMouseDown(EventMouseDown &e)  {
	if (e.button == 1) {
		reset();
	}
	e.consumed = true;
	e.target = this;
        setDestination(e.pos.x, e.pos.y);
  }

Where EventMouseDown was coming from “nanovg.h”

I’m now trying to port these modules to working with the new Rack (current 2.3)

And I just set up my development environment, downloaded the latest SDK etc. But when I try to compile I’m getting a lot of errors like

src/SlowControllers.hpp:31:22: error: 'EventMouseDown' has not been declared
   31 |     void onMouseDown(EventMouseDown &e) override;

Is Rack now using a version of nanovg which doesn’t have things like EventMouseDown?

Is there anywhere I can see the documentation for the version of the graphics library Rack2 is using?

AFAIK nanovg is solely vector graphics and doesn’t deal with input.

Not an expert here, just on the same learning curve, but I think what you’re looking for is to override OnHover, OnButton (for mouse down), onDragHover (for captured mouse movement), etc… in your subclass of Widget.

1 Like

Yes. You’re right.

It doesn’t have anything to do with nanovg. I was deriving my class from ParamWidget … and presumably that no longer has this method. In fact I can’t even find ParamWidget now, possibly it’s been renamed / deprecated in favour of something else.

Looks like event-consuming widgets should dervice from OpaqueWidget.

Most of this isn’t hard to figure out if you read the source. The API docs are mainly useful for browsing and the generated diagrams. The actual written documentation present is inadequate - merely a regurgitation of extremely sparse comments.

1 Like

It’s funny. I used to think VCV Rack was incredibly well documented. I’d have never made the progress I made with 0.6 if it weren’t.

But I think it’s changed so much I have to go back and learn it all again. (And tbh I seem to have forgotten a lot of what I understood 4 years ago).

Actually I found ParamWidget. But I can’t find the equivalent of MouseDown. :frowning_face:

But I’ll take your hint and try OpaqueWidget instead.