Browse Source

DragAndDropContainer: Fix the escape key dismissing the drag operation

pull/22/head
attila 3 years ago
parent
commit
032cc528c8
1 changed files with 9 additions and 3 deletions
  1. +9
    -3
      modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp

+ 9
- 3
modules/juce_gui_basics/mouse/juce_DragAndDropContainer.cpp View File

@@ -59,6 +59,7 @@ public:
startTimer (200); startTimer (200);
setInterceptsMouseClicks (false, false); setInterceptsMouseClicks (false, false);
setWantsKeyboardFocus (true);
setAlwaysOnTop (true); setAlwaysOnTop (true);
} }
@@ -200,7 +201,12 @@ public:
{ {
if (key == KeyPress::escapeKey) if (key == KeyPress::escapeKey)
{ {
dismissWithAnimation (true);
const auto wasVisible = isVisible();
setVisible (false);
if (wasVisible)
dismissWithAnimation (true);
deleteSelf(); deleteSelf();
return true; return true;
} }
@@ -466,8 +472,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
dragImageComponent->setOpaque (true); dragImageComponent->setOpaque (true);
dragImageComponent->addToDesktop (ComponentPeer::windowIgnoresMouseClicks dragImageComponent->addToDesktop (ComponentPeer::windowIgnoresMouseClicks
| ComponentPeer::windowIsTemporary
| ComponentPeer::windowIgnoresKeyPresses);
| ComponentPeer::windowIsTemporary);
} }
else else
{ {
@@ -484,6 +489,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
dragImageComponent->sourceDetails.localPosition = sourceComponent->getLocalPoint (nullptr, lastMouseDown); dragImageComponent->sourceDetails.localPosition = sourceComponent->getLocalPoint (nullptr, lastMouseDown);
dragImageComponent->updateLocation (false, lastMouseDown); dragImageComponent->updateLocation (false, lastMouseDown);
dragImageComponent->grabKeyboardFocus();
#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