C++ 101 question - ITextControl

SetStr(const char* str) is a public member function of ITextControl which inherits from IControl.

We instantiate an ITextControl in the mLayoutFunc section of iPlug like this:

pGraphics->AttachControl(new ITextControl(IRECT(240, 50, 250, 60), "Start Text"), kTextTag);

which creates a new instance of an ITextControl referenced by the kTextTag.

So how come I can’t access/update the text string in this control later on by doing this:

GetUI()->GetControlWithTag(kTextTag)->SetStr("New Text");

compiler says the control has no member function “SetStr()”. Why is that?

GetControlWithTag() returns an IControl* . You can dynamic cast that to an ITextControl*. There is a helper you can use. E.g



Excellent! Thank you for the lesson and the tip. Now that you’ve pointed that out I see that dynamic cast helper used a lot in the IPlugControls example (which I didn’t understand previously).