Hi all. I’m officially stuck and some help would be appreciated!
In the JUCE Drag and Drop demo, they use ListBox and ListBoxModel. In short, the ListBoxModel creates a list of items using paintListBoxItem() and uses getDragSourceDescription() to communicate with a parent component inheriting DragAndDropContainer to enable a drag and drop operation.
I’m using a more complex implementation of this based off this tutorial using TableListBox and TableListBoxModel. Instead of painting items, I’m using a child class deriving from Label and the model reads an XML to create a table of labels.
The problem I’m having is how to make these Labels behave like the items in the demo so I can drag and drop them to a target.
I thought this would be as simple as overriding TableBoxModel’s getDragSourceDescription()
The problem here is that the caller of this is inside mouseDrag() inside TableListBox::RowComp, a private class of TableListBox. You can override getCellComponent() which returns a Component* but I need it to call mouseDrag() from TableListBox::RowComp, not a generic Component.
I thought calling TableListBox’s refreshComponentForRow() would pass my mouse events on to the TableListBox::RowComp`, as it calls
static_cast<RowComp*> (existingComponentToUpdate)->update (rowNumber, rowSelected);
But it seems I’m missing something else…any clues?
On a wider note, I find this group of classes as a whole to be a little confusing. TableBoxModel is not a component, but does component things - painting, creating other components etc. Also, TableBoxModel doesn’t inherit ListBoxModel like I would have thought. Yet, TableListBox is a component, but inherits ListBoxModel. When I think “model”, I guess I think data…not UI. Am I misguided? Thanks for any help!
Update: I fixed it! I forgot to ensure my Label doesn’t intercept the mouse clicks for the model by calling setInterceptsMouseClicks (false, false); in the constructor of the Label.
