Hi,
I think there’s something wrong with this line:
Shouldn’t the return type be TableListBox
?
TableListBox& getOwner() const { return owner; }
I can’t get my TableListBoxModel::getDragSourceDescription()
method to be called without this modification.
Thanks for your insight.
Here’s a PIP to reproduce the issue (row drag and drop not working):
/*******************************************************************************
BEGIN_JUCE_PIP_METADATA
name: ComponentWithListRowMouseBehavioursTest
dependencies: juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
exporters: VS2022, XCODE_MAC
moduleFlags: JUCE_STRICT_REFCOUNTEDPOINTER=1
type: Component
mainClass: MainComponent
END_JUCE_PIP_METADATA
*******************************************************************************/
#pragma once
//==============================================================================
class MainComponent : public juce::Component,
public juce::DragAndDropContainer,
private juce::TableListBoxModel
{
public:
//==============================================================================
MainComponent()
{
addAndMakeVisible (table);
table.setModel (this);
table.getHeader().addColumn ("Column 1", 1, 100);
table.getHeader().addColumn ("Column 2", 2, 100);
setSize (600, 400);
}
~MainComponent() override {}
void paint (juce::Graphics& g) override { g.fillAll (juce::Colours::black); }
void resized() override { table.setBounds (getLocalBounds()); }
private:
TableListBox table;
int getNumRows() override { return 500; }
void paintRowBackground (Graphics& g, int rowNumber, int width, int height, bool rowIsSelected) override
{
g.fillAll (rowIsSelected ? juce::Colours::white : juce::Colours::black);
}
void paintCell (Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override
{
g.setColour (rowIsSelected ? juce::Colours::black : juce::Colours::white);
g.drawText (String (rowNumber), 0, 0, width, height, juce::Justification::centredLeft, false);
}
var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows) override
{
return {"whatever"};
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
I think something is wrong here:
Seems that for some reason m
is not the expected type (actual model) so the call to m->getDragSourceDescription (rowsToDrag)
returns a void var
, etc…