iPlug2 Forum

Subcomponents with Control Tags

I’m trying to make a subcomponent, to keep things tidy.
Taking inspiration from IVNumberBoxControl, I overrode IControl::OnAttached

 void OnAttached() override
  {
    IRECT b = mWidgetBounds;
    GetUI()->AttachControl(mScopeControl = new IVScopeControl<2,128>(b.GetGridCell(0, 0, 1, 2), "Scope_101"), scopeCtrlTag);
  }

The main difference you can see here is that I’m attaching with a control Tag.

After resizing, this triggers the assertion at line 303 of IGraphics.cpp

    assert(result.second && "AttachControl failed: ctrl tags must be unique");

How can I solve this?
If my approach is wrong, what should I do to create a wrapper component, like JUCE’s Component?

I would recommend you don’t try this for now. There is some work on a branch to make child controls work, but I didn’t have much time to work on it

Ok, thank you for answering! I hope you can find the time to make it work eventually, it is difficult for me to contribute to that branch because I’m not very familiar with the codebase.

To amend what I wrote before, the cause of the error was that I attached the parent control multiple times.
Now it seems to work just fine :wink: