findParentDragContainerFor question

Just wondering if someone could give me some advice about the following - I’m wanting to do a drag and drop from a tabbedcomponent and have set it’s parent component as a DragDropContainer. However, when I come to use findParentDragContainerFor to locate this from within the tabbedcomponent it’s not returning anything. Stepping through this it seems that the parentcomponent has not been set.

Obviously if I could add a property to my tabbedcomponent and set the dragdropcontainer that way, but I can’t help feeling that there must be a more elegant solution that using the findParentDragContainerFor. Any pointers about where I might be going wrong would be much appreciated.

What are you passing to findParentDragContainer? Just sounds like you’re giving it your top-level component or something?

I’m passing in my tabbedcomponent, which is sitting on a top level component set as the DragDropContainer. However, I’ve been rethinking this overnight and am now thinking that I should probably set the tabbed components TabbedButtonBar as the DragDropContainer and then use the TabBarButton controls to call the startdragging. Does that sound about right?

Cheers for your help!

No, definitely not - the dragdropcontainer should be a top-level component, because only comps inside it will be able to receive the drags.

Thanks for the response about the drag and drop, which was very helpful. After a bit more tweaking I’ve got it working nicely now, so your pointer was much appreciated.

I’ve got stuck with a different issue though now, which needs overcoming before the extended tabbed component is complete. It seems that some of the important functionality for the tabbed component is contained in TabCompButtonBar, which is declared as a friend class presumably so that it can invoke the changeCallback method. However, this causes problems if you inherit the TabbedButtonBar, as you’re not then able to call changeCallback, as it’s not set as a friend class. It doesn’t seem possible to inherit from TabCompButtonBar without hacking the framework, as it is not declared in the juce header. Is there a way around this that I’m missing?

Many thanks


Well, not knowing what you’re trying to do makes it tricky to know what to suggest, but if you can think of any clean, generic changes that would make it more versatile, let me know.

Perhaps the cleanest option would be to include the TabCompButtonBar in the juce header so we could inherit from this rather than the TabbedButtonBar, as this seems to be the more useful class to use when customising the TabbedComponent. Hopefully this shouldn’t cause any compatibility issues for anyone too.

No, I don’t like the idea of that - it’s a private implementation class, and could change in the future, I don’t really want people using it directly. What exactly are you trying to customise that requires access to that class?

I had a rethink and worked out what to do - my problem was the owner of my extended TabBarButton was a TabCompButtonBar but this was unusable and not something I could cast into. To get around this I had extended the TabbedButtonBar and was using this as the buttons owner, but this then had the problem that I could not call changeCallback in the TabbedComponent. After a step back, I realised that I just needed to pass a reference to the parent TabbedComponent in my createTabButton and use that from the mouseDrag instead. Simple really I know… Thanks for your interest though!!