Browse Source

When dragging-and-dropping, made the escape key cancel the drag.

tags/2021-05-28
jules 12 years ago
parent
commit
177b6426b8
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp

+ 18
- 0
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -172,6 +172,23 @@ public:
} }
} }
bool keyPressed (const KeyPress& key) override
{
if (key == KeyPress::escapeKey)
{
dismissWithAnimation (true);
delete this;
return true;
}
return false;
}
bool canModalEventBeSentToComponent (const Component* targetComponent) override
{
return targetComponent == mouseDragSource;
}
private: private:
DragAndDropTarget::SourceDetails sourceDetails; DragAndDropTarget::SourceDetails sourceDetails;
Image image; Image image;
@@ -400,6 +417,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
static_cast <DragImageComponent*> (dragImageComponent.get())->updateLocation (false, lastMouseDown); static_cast <DragImageComponent*> (dragImageComponent.get())->updateLocation (false, lastMouseDown);
dragImageComponent->setVisible (true); dragImageComponent->setVisible (true);
dragImageComponent->enterModalState();
#if JUCE_WINDOWS #if JUCE_WINDOWS
// Under heavy load, the layered window's paint callback can often be lost by the OS, // Under heavy load, the layered window's paint callback can often be lost by the OS,


Loading…
Cancel
Save