Issue with combobox listener in multiple toolbars


#1

Hi all,

I’m starting to tackle the listeners etc in my new app,
and getting some strange behaviour regarding toolbars.

I’ve got a 3 components, which all have they’re own toolbars.
The components are constructed independently,
all create they’re own ToolBar’s with they’re own toolbaritemfactories.

There’s no link between them at any place.

The toolbar contains a combobox as a customtoolbar component.
I’ve added a combobox listener to the component which handles the toolbar.

If i change a combobox, all components receive the change.

This is a real showstopper as i’ve wasted all day on it trying to figure it out, would appreciate any help…

Thnx,
Radiance


#2

here’s some code to illustrated which i copied from the rather large bulk of it:


class WorkPaneToolbarItemFactory   : public ToolbarItemFactory
{
public:
	WorkPaneToolbarItemFactory(MyComponent *m:
		myComponent(m)
	{}

...

	ToolbarItemComponent* createItem (const int itemId)
	{
		switch (itemId)
		{

...

		case PaneSelection:
			return new PaneSelectionToolbarComboBox (itemId, myComponent);

		default:
			break;
		}

		return 0;
	}

private:

	MyComponent* myComponent;


	// Custom ComboBox for Pane Selection
	class PaneSelectionToolbarComboBox : public ToolbarItemComponent
	{
	public:
		PaneSelectionToolbarComboBox (const int toolbarItemId, myComponent *m)
			: ToolbarItemComponent (toolbarItemId, T("Pane Selection"), false)
		{

...

			// Add the Combo box listener
			comboBox->addListener(m);
		}

...

};


// ------------------------------------------------------------------------------------------------------


class MyComponent   : public Component,
                          public ButtonListener, public ComboBoxListener
{
public:
	WorkPaneComponent ()	
	{
		// Create Toolbar Item Factory
		factory = new WorkPaneToolbarItemFactory(workPaneNode, this);

		// Create and add the toolbar...
		addAndMakeVisible (toolbar = new Toolbar());

		// And use our item factory to add a set of default icons to it...
		toolbar->addDefaultItems (*factory);
	}	


...


	void comboBoxChanged (ComboBox *comboBoxThatHasChanged)
	{

		int id = comboBoxThatHasChanged->getSelectedId();
	}

...
    Toolbar* toolbar;
    WorkPaneToolbarItemFactory *factory;
};

Basically,
If i now use X components in my app, all these components all receive the combobox changed events.
It’s as if juce were limited to only have 1 toolbar per app.

I need different toolbars per component, and a combobox to change the component’s behaviour and children…

Help appreciated, i’m stuck :slight_smile:

Radiance


#3

It’s safe to say that a combobox won’t send messages to components that haven’t been added to it as listeners. If I were you I’d stick some breakpoints in the ComboBox::addListener method and see if you can spot where it’s going wrong. It’ll probably just be a silly mistake somewhere.


#4

ok, i think i might stop for today and start with a fresh mind tomorrow, i’ve been overdoing it a bit me things :slight_smile:

Thanks,
Radiance


#5

Where you able to fix the issue?