/******************************************************************************* The block below describes the properties of this PIP. A PIP is a short snippet of code that can be read by the Projucer and used to generate a JUCE project. BEGIN_JUCE_PIP_METADATA name: ComponentDragTest dependencies: juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics exporters: vs2017 type: Component mainClass: ComponentDragTest END_JUCE_PIP_METADATA *******************************************************************************/ #pragma once //============================================================================== class ComponentDragTest : public Component { public: //============================================================================== ComponentDragTest() { setSize (600, 400); addAndMakeVisible (dot); } //============================================================================== void paint (Graphics& g) override { g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); } private: class Dot : public Component { ComponentDragger dragger; public: Dot() { setSize (20, 20); } void paint (Graphics& g) override { g.setColour (Colours::lightgreen); g.fillEllipse (getLocalBounds().toFloat()); } void mouseDown (const MouseEvent& e) override { dragger.startDraggingComponent (this, e); } void mouseDrag (const MouseEvent& e) override { dragger.dragComponent (this, e, nullptr); } }; Dot dot; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComponentDragTest) };