Browse Source

Added callbacks to DragAndDropContainer to be told when drag operations begin/end.

tags/2021-05-28
jules 11 years ago
parent
commit
c6ca8b05b1
2 changed files with 22 additions and 4 deletions
  1. +16
    -4
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp
  2. +6
    -0
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h

+ 16
- 4
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -69,6 +69,8 @@ public:
if (current->isInterestedInDragSource (sourceDetails))
current->itemDragExit (sourceDetails);
}
owner.dragOperationEnded();
}
void paint (Graphics& g) override
@@ -164,14 +166,14 @@ public:
if (sourceDetails.sourceComponent == nullptr)
{
delete this;
deleteSelf();
}
else if (! isMouseButtonDownAnywhere())
{
if (mouseDragSource != nullptr)
mouseDragSource->removeMouseListener (this);
delete this;
deleteSelf();
}
}
@@ -180,7 +182,7 @@ public:
if (key == KeyPress::escapeKey)
{
dismissWithAnimation (true);
delete this;
deleteSelf();
return true;
}
@@ -311,12 +313,17 @@ private:
&& ModifierKeys::getCurrentModifiersRealtime().isAnyMouseButtonDown())
{
(new ExternalDragAndDropMessage (files, canMoveFiles))->post();
delete this;
deleteSelf();
}
}
}
}
void deleteSelf()
{
delete this;
}
void dismissWithAnimation (const bool shouldSnapBack)
{
setVisible (true);
@@ -449,6 +456,8 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
if (ComponentPeer* const peer = dragImageComponent->getPeer())
peer->performAnyPendingRepaintsNow();
#endif
dragOperationStarted();
}
}
@@ -473,6 +482,9 @@ bool DragAndDropContainer::shouldDropFilesWhenDraggedExternally (const DragAndDr
return false;
}
void DragAndDropContainer::dragOperationStarted() {}
void DragAndDropContainer::dragOperationEnded() {}
//==============================================================================
DragAndDropTarget::SourceDetails::SourceDetails (const var& desc, Component* comp, Point<int> pos) noexcept
: description (desc),


+ 6
- 0
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h View File

@@ -165,6 +165,12 @@ protected:
virtual bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
StringArray& files, bool& canMoveFiles);
/** Subclasses can override this to be told when a drag starts. */
virtual void dragOperationStarted();
/** Subclasses can override this to be told when a drag finishes. */
virtual void dragOperationEnded();
private:
//==============================================================================
class DragImageComponent;


Loading…
Cancel
Save