Change title of CTextButton When clicking on another button

Hello!

I am using the standalone example application to test a certain feature that I am trying to implement.
In the testmodel.cpp in the function onEndEdit, when clicking on the textbutton with control-tag “ShowAlert” I am starting a timer with a callback. When the timer expires my callback gets executed exactly as I want.

The next step I want to be able to do is to change the title text of the textbutton connected to “ShowAlert2” control-tag when the timer expires. I dont want to change the value of the control (ShowAlert2) itself but just want to get a handle to the control to be able to execute setTitle function for that control. My callback function somehow need to notify that the other button needs to redraw itself or something?

Is it possible to do what I want in some way? Since it is a CTextbutton and not a label I cannot just do:
Value::performStringValueEdit(*getValue(“ShowAlert2”), “new title”);

I have tried to override the valueChanged function in testdelegate.cpp but in that case I need to change the control value itself with v.performEdit(0.) for it to be executed, and also it gets called for every event that happens (mouseDown, mouseMove,mouseUp). I just want the title to change on the other button when MouseUp event is happening on the button with control-tag “ShowAlert” if thats the only way to achieve this behaviour

Best regards,
Erik

1 Like

I’ve been doing this to get a particular control from its tag, which is undoubtedly not the best way to do it but it does work, maybe somebody wiser can show a better way…

CView* VZV_PD10Controller::getControlFromTag(int32_t tagNum)
{
	CView* result = nullptr;
	CView* root;

	if (edView != nullptr)
	{

		root = edView->getFrame()->getView(0);	//this is the mother view
		vector<CControl*> controlViews;
		uint32_t nViews;

		if (CViewContainer* rootAsContainer = root->asViewContainer())
		{
			nViews = rootAsContainer->getChildViewsOfType<CControl>(controlViews);
			for (CControl* cntrl : controlViews)
			{
				if (cntrl->getTag() == tagNum)
				{
					result = cntrl;
				}
			}
		}

		return result;
	}

	else

	{
		return nullptr;
	}
}

Are you using this in a standalone application or a plugin?