void mouseUp (const MouseEvent& e) { if (e.originalComponent != this) { if (mouseDragSource != nullptr) mouseDragSource->removeMouseListener (this); // (note: use a local copy of this in case the callback runs // a modal loop and deletes this object before the method completes) DragAndDropTarget::SourceDetails details (sourceDetails); DragAndDropTarget* finalTarget = nullptr; const bool wasVisible = isVisible(); setVisible (false); Component* unused; finalTarget = findTarget (e.getScreenPosition(), details.localPosition, unused); if (wasVisible) // fade the component and remove it - it'll be deleted later by the timer callback dismissWithAnimation (finalTarget == nullptr); if (getParentComponent() != nullptr) getParentComponent()->removeChildComponent (this); if (finalTarget != nullptr) { currentlyOverComp = nullptr; finalTarget->itemDropped (details); } // careful - this object could now be deleted.. } }
bool keyPressed (const KeyPress& key) override { if (key == KeyPress::escapeKey) { dismissWithAnimation (true); delete this; return true; } return false; }