bool ComponentPeer::handleDragDrop (const ComponentPeer::DragInfo& info) { handleDragMove (info); Component* const targetComp = dragAndDropTargetComponent; if (targetComp != nullptr) { dragAndDropTargetComponent = nullptr; lastDragAndDropCompUnderMouse = nullptr; if (DragHelpers::isSuitableTarget (info, targetComp)) { if (targetComp->isCurrentlyBlockedByAnotherModalComponent()) { targetComp->internalModalInputAttempt(); if (targetComp->isCurrentlyBlockedByAnotherModalComponent()) return true; } (new DragHelpers::AsyncDropMessage (targetComp, info))->post(); return true; } } return false; }
bool ComponentPeer::handleDragExit (const ComponentPeer::DragInfo& info) { DragInfo info2 (info); info2.position.setXY (-1, -1); const bool used = handleDragMove (info2); jassert (dragAndDropTargetComponent == nullptr); lastDragAndDropCompUnderMouse = nullptr; return used; }
bool ComponentPeer::handleDragDrop (const ComponentPeer::DragInfo& info) { handleDragMove (info); if (WeakReference<Component> targetComp = dragAndDropTargetComponent) { dragAndDropTargetComponent = nullptr; lastDragAndDropCompUnderMouse = nullptr; if (DragHelpers::isSuitableTarget (info, targetComp)) { if (targetComp->isCurrentlyBlockedByAnotherModalComponent()) { targetComp->internalModalInputAttempt(); if (targetComp->isCurrentlyBlockedByAnotherModalComponent()) return true; } ComponentPeer::DragInfo infoCopy (info); infoCopy.position = targetComp->getLocalPoint (&component, info.position); // We'll use an async message to deliver the drop, because if the target decides // to run a modal loop, it can gum-up the operating system.. MessageManager::callAsync ([=] { if (auto* c = targetComp.get()) { if (DragHelpers::isFileDrag (info)) dynamic_cast<FileDragAndDropTarget*> (c)->filesDropped (infoCopy.files, infoCopy.position.x, infoCopy.position.y); else dynamic_cast<TextDragAndDropTarget*> (c)->textDropped (infoCopy.text, infoCopy.position.x, infoCopy.position.y); } }); return true; } } return false; }