The WYSIWYG editor for VSTGUI 4 works decent. I have integrated this out-of-the-box with the project generator app.
My only problem is, what to do, when I want to access a control from code? Where do the CControl objects live that I have defined in the *.uidesc JSON file?
I have seen that maybe sub-controllers give fine control, but it’s not clear how to set / register this to get hold on the view object.
I can create my own custom view with a factory, sure, but I was expecting something like this:
UIViewFactory->getViewById(someUniqueIDOrName) which will then provide the control for further updates. But it seems such thing does not exist?
What is the best approach to set a CTextLabel in VSTGUI editor and then updating the label’s text from code? How a developer can access the CTextLabel object: It seems to live somewhere, but I do not know where, so I’ll probably have to end up by creating a custom view inheriting CTextLabel - instead.
See here for an example on how to create sub-controllers.
I believe he wish to know how to retrieve pointer to the specific View on the GUI.
What are exactly subcontrollers?
I am not an expert and this may be a bad way of doing things, but after much headscratching (and Googling and ChatGPTing) I got this function which I put in controller.cpp:
CView* PD10_MyController::getControlFromTag(int32_t tagNum)
CView* result = nullptr;
CView* root = edView->getFrame()->getView(0); //this is the mother view
if (CViewContainer* rootAsContainer = root->asViewContainer())
nViews = rootAsContainer->getChildViewsOfType<CControl>(controlViews);
for (CControl* cntrl : controlViews)
if (cntrl->getTag() == tagNum)
result = cntrl;
This assumes the control has a tag, and tagnum is the tag number while edview is the editor view which is a copy of variable view in the createview(FIDString name) method. It seems unnecessarily difficult and maybe one is supposed to have some different paradigm but I’m finding documentation a trifle sparse. It would be nice to have just some collection of views/controls available but so far as I know there isn’t one.
Anyway hope this helps.
That’s indeed one of the most inefficient ways in doing it, but may work in your special case.
It’s more efficient when working with the
IController::verifyView(..) method and remember the control with the tag in a member variable.
Well I’m sure it is inefficient, but honestly the documentation is somewhat sparse. It’s like searching for needles in a haystack. Maybe Steinberg could make it more comprehensive so that n00bs like me don’t have to flounder around just trying to grasp the API?
Here’s a concrete example of using
viewIsBeingDeleted, because you don’t want dangling pointers!)
CView* MyController::verifyView(CView* view, const UIAttributes& attributes, const IUIDescription* description)
if (auto control = dynamic_cast<CTextLabel*>(view); control && control->getTag() == kMyTag)
myTextLabel = control;
void MyController::viewIsBeingDeleted(CView* view)
if (view == myTextLabel)
myTextLabel = nullptr;