This tutorial will teach you how to add a button to a processor's editor, the interface that appears in the EditorViewport. There are a number of steps involved, which must be followed carefully if you want the button to work. Ideally, buttons would be added automatically once you define the parameters for your processor, but coming up with an elegant implementation is a lot of work. Until then, you'll have to add buttons manually.
...
- If they don't already exist, add "void loadEditorParameters(XmlElement*);" and "void saveEditorParameters(XmlElement*);" methods to your editor's header file.
- Inside the saveEditorParameters method, you need to add a new XML element and set an attribute that corresponds to the button state:
Code Block theme Confluence language cpp title parameter saving void MyEditor::saveEditorParameters(XmlElement* xmlParent) { XmlElement* parameterChild = xmlParent->createNewChildElement("PARAMETERS"); infoparameterChild->setAttribute("ButtonState",buttonName->getToggleState()); }
Inside the loadEditorParameters method, check the variable and use it to set the button state. If you set the "sendNotification" variable to "true," the software will behave as though the button were clicked by the user. So any actions that are associated with that button will be carried out.
Code Block theme Confluence language cpp title parameter loading void MyEditor::loadEditorParameters(XmlElement* xmlParent) { forEachXmlChildElement(*xmlParent, xmlNode) { if (xmlNode->hasTagName("PARAMETERS")) { buttonName->setToggleState(xmlNode->getBoolAttribute("ButtonState"), true); } } }
- Make sure your tag name and attribute name are exactly the same as what you used in the "saveEditorParameters" method!
...