How to Receive comboBoxChanged() Messages from CustomToolbarComboBox in JUCE demo?


What specific code would one have to add to JUCE demo to enable the CustomToolbarComboBox to send change messages to ToolbarDemoComp main panel? For example, to change a TextBox in ToolbarDemoComp main panel?

I set my container that contains the toolbar as a Button::Listener, and put the following code in the constructor.

toolbar.addDefaultItems (factory);
for (int i=0; i<toolbar.getNumItems(); i++)

It can receive buttonClicked() messages from toolbar buttons as follows

void ViewerFrame::buttonClicked (Button* button)
    int i=0;
    for (i=0;i<toolbar.getNumItems();i++)
        if (button == toolbar.getItemComponent(i))
    int id = toolbar.getItemId(i);
    if (DemoToolbarItemFactory::DemoToolbarItemIds::doc_open == id)
        std::cout << "open " << "\n";
    else if(DemoToolbarItemFactory::DemoToolbarItemIds::doc_save == id)
        std::cout << "save " << "\n";
    else if(DemoToolbarItemFactory::DemoToolbarItemIds::doc_saveAs == id)
        std::cout << "saveAs " << "\n";

I’m not sure if this is the best way to do this but it works.

I also made my toolbar’s container be a ComboBox::Listener and added a comboBoxChanged () method, but I don’t receive messages from the ComboBox, I assume because the above addListener does not work for a custom component?

What is the correct way to do this?