Elegant way for a ParamWidget to control N ParamQuantities?

Forgive me if this has already has been discussed. I didn’t find anything with the search.

Ideally, I would like to have a ParamId/ParamQuantity that points to a vector value rather than scalar. But everything is reliant on a 1:1 relationship between ParamId and a scalar float.

So then, I thought to implement a ParamWidget that could control N ParamQuantities. In particular, for now, N = 2 (x & y coordinates of a point).

The problems I see so far:

  1. Not being able to override resetAction() for the history. Not ideal, but I could replicate the same code for the extra ParamQuantities in reset().

  2. Not being able to override createContextMenu() to account for the extra parameters for user input via TextField. I’m not sure if there is an elegant work around for this. I found a thread where override onButton was frowned upon to create a custom context menu. Not elegant, but I was thinking perhaps a custom ParamQuantity for the ‘main’/‘first’ parameter that would parse the single text field and send the values to its siblings. This would work OK for now since N = 2 so it’s not too many parameters stuck in one field. But then also, the parameter change histories would need to be addressed…

  3. Not being able to override ModuleWidget.getParam(). I couldn’t find where ModuleWidget.getParam() was being called so that may not be too much of an issue?

There are probably many other issues, but these were the initial ones I found while planning out this custom ParamWidget. Are there better ways to work around these issues or a better solution in general?

Is there a reason you want to use ParamWidget? You can create your custom widget which “controls” as many ParamQuantity instances as you like but of have to implement it yourself.

I have thought about that and originally started with just a generic OpaqueWidget, but wanted to keep (without replicating) a lot of the ParamWidget functionality like the context menu for entering text for the values, MIDI mapping, history, etc.

If I have to just implement a generic widget, then that will work. Maybe I am overcomplicating this. That may actually be easier. I would just have to remember if I re-use the class that I may have to have the parent ModuleWidget call its reset, etc since it wouldn’t be in its param collection.

Thanks!

As far as I know there is no other way.

That doesn’t make much sense if you think about it. When I right-click on your ParamWidget-derived widget, how should the default context menu show two values?

Oops! I guess it doesn’t make sense. I originally thought it might be easy to add another text box via override or for the simple N=2 case, maybe a single text box input like “(x, y)” and parse… I was probably thinking about it the wrong way. Thanks!