Hi, I’ve problems doing a simple drag’n’drop. I don’t know what I doing wrong:
The component that I want drag:
class Movil: public Button, public DragAndDropContainer
{
public:
Movil();
~Movil();
juce_UseDebuggingNewOperator;
void paintButton(Graphics &g, bool isMouseOverButton, bool isButtonDown);
void clicked();
};
Its pure virtual method implementation:
[code]void Movil::clicked()
{
startDragging(“prueba”, this);
}
void Movil::paintButton(Graphics &g, bool isMouseOverButton, bool isButtonDown)
{
g.setColour(Colours::black);
g.fillRect(0, 0, getWidth(), getHeight());
}
[/code]
Its target (which contains an Movil object):
class MainComponent : public Component,
public ButtonListener,
public DragAndDropTarget
private:
MenuBarComponent* menu;
Menu* menuc;
Movil* movil;
public:
MainComponent ()
{
movil = new Movil;
addAndMakeVisible(movil);
movil->setBounds(15,15,50,30);
//... other few new objects
}
~MainComponent ()
{
deleteAllChildren();
}
bool isInterestedInDragSource (const String &sourceDescription, Component *sourceComponent)
{
return true;
}
void itemDropped(const String & sourceDescription,Component *sourceComponent,int x,int y)
{
sourceComponent->setBounds(x, y, 50, 30);
}
};
I don’t understand what I’m doing wrong. I want drag movil (which inside of maincomponent already) to another place of maincomponent, but I cannot. However I can move it if I release the drop inside movil object.
Any help will be welcome!

