Implementing ctrl+drag on a custom control for fine tuning?

Hello! I’m working on a sequencer that looks like this:

image

The mouse is used to adjust the heights of those bars. When dragging a bar up or down, the mouse cursor is still visible.

A astute user pointed out that many modules use the control keys for fine tuning. A good example of this is the SliderSeq:

image

Some things I noticed about SliderSeq:

  1. When you start dragging a slider, the mouse disappears. I’ve noticed this on all knobs in VCV Rack as well.

  2. When you hold Ctrl while dragging, the slider changes less when you drag it (for fine tuning). Again, this is the same for knobs in VCV Rack too.

  3. While dragging either a slider or knob, the mouse cursor position is not modified. In other words, when you start dragging, the mouse disappears. When you’re done dragging and release the mouse button, the mouse cursor is right where it left off.

So it looks like VCV rack has this concept of fine-tuning built in to the controls. Has anyone implemented this type of fine-tuning control on a custom widget that I can see? I’m very interested if it’s possible and if so, where can I learn more about it?

Cheers,
Bret

Make your widget a subclass of SliderKnob and you’ll get all the behavior of Knob and ParamWidget.

Thanks Andrew. I may back off this strategy since I love the ability to be able to “paint” the bars on the sequencer horizontally. I might think of some other way to allow for fine-tuning.

You could implement a right click text box, so someone can type a specific value. Have a look at the ParamTooltip class in ParamWidget.

@carbon14 Would you happen to have to know of any example code that does this?

All my examples are wrapped up in a framework and are probably more complicated to understand than what’s in ParamWidget.cpp.

If you really want it, look at the EventParamField in this source https://github.com/david-c14/SubmarineFree/blob/master/src/shared/EventWidgets.cpp