Problems dragging a component

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.fillRect(0, 0, getWidth(), getHeight());

Its target (which contains an Movil object):

class MainComponent  : public Component,
						public ButtonListener,
						public DragAndDropTarget
   MenuBarComponent* menu;
   Menu* menuc;
   Movil* movil;
    MainComponent ()
      movil = new Movil;
      //... other few new objects

    ~MainComponent ()
	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!

It’s your top-level parent component or window that needs to be a DragAndDropContainer, not the thing you’re trying to drag!

Thanks you jules, i was confused :slight_smile: