Responding to Button click

So I have a ViewContainer defined in the GUI Editor. I added the subcontroller attribute “ButtonController” to this ViewContainer.

Within this ViewContainer I have added a COnOffButton.
When I click this button, I want it to respond.

Here’s the code

IController* MainController::createSubController(UTF8StringPtr _name, 
          const VSTGUI::IUIDescription* /*description*/,VSTGUI::VST3Editor* editor)
        ConstString name(_name);
   	if (name == "ButtonController")
 		 return new ButtonController(editor);
 	return nullptr;

Here’s the ButtonController class :

class ButtonController : public VSTGUI::DelegationController
		ButtonController(VSTGUI::IController* parent) : DelegationController(parent) {};
		IControlListener* getControlListener(VSTGUI::UTF8StringPtr controlTagName)	override {	return this;}
		void valueChanged(VSTGUI::CControl* pControl)	
            // this is not invoked on button click

I expect valueChanged function to be invoked on button click. But it never does. What am I missing ?

I would also think that this should work. Did you test that the button controller is created and that the ButtonController::getControlListener() is called?

The thing I was missing here was adding a Control tag to the button. It seems this is compulsory.

Though all I needed was a button to exchange view from one template to another. I do not need a new parameter defined just for this. My current solution is to define a dummyParameter just for this. But then I am exposing a parameter to end user when it serves no practical purpose.

Is there a way to hide such dummy params like this ?

Or Is there a way to create Control tag without defining a parameter ?