Check if a knob is pressed

Hi there,

I’m working using a basic RoundBlackKnob knob (i.e. a ParamWidget):

addParam(ParamWidget::create<RoundBlackKnob>(Vec(col1, row3), module, NWK::RISE_AMP_PARAM, 0.0, 1.0, 1.0));

Is it possible to check if the param is pressed (i.e. I’m moving/dragging it, or simply mouseDown on it with mouse stable)?
Because, due to this check, I’d like to draw (::draw()) some stuff instead of others.

Any clues?

Thanks

Subclass RoundBlackKnob (or whatever you want) and override onDragStart and onDragEnd methods. Remember to call the superclass somewhere in those methods.

I see.

But to kept the same behaviour, I believe (since its virtual) that I also need to “propagate” the original Knob::onDragStart code right?

Such as:

void MyCustomKnob::onDragStart(EventDragStart &e) {
	// my new fancy code

	// propagate old code
	windowCursorLock();
	dragValue = value;
	randomizable = false;
}

Do you mean this way?

No, just call the superclass method :stuck_out_tongue: RoundBlackKnob::onDragStart(e)

1 Like

Right, true! I usually call superclass when I hide parent class, not with virtual/overriding. But yes, it simply works!

Just one thing is not clear to me: why, using SDK, I’m able to place this code on my cpp file?

void SVGKnob::onChange(EventChange &e) {
    // some mine stuff

    dirty = true;
    Knob::onChange(e);
}

Shouldn’t this “fail” since I’m definiing it twice?
I mean: once you load my DLL, that method is already defined in your app (here).

Shouldn’t got an error when I re-define it (probably at run time)?
How can it know which method to use if its defined basically twice?

Probably its a DLL behaviour, which I don’t know :grin:
Can you shine me?

Thanks

The dynamic linker only attempts to link undefined symbols. Redefining Rack symbols in this way is considered “undefined behavior” and should not be attempted.