From 629a3ca14b32a1d8b249de5cd411eef10af388dc Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 16 Feb 2023 20:04:56 +0000 Subject: [PATCH] ListBox: Allow ListBoxModel to control whether items may be dragged to other windows --- modules/juce_gui_basics/widgets/juce_ListBox.cpp | 2 +- modules/juce_gui_basics/widgets/juce_ListBox.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 43700aa34b..24d52fa5bc 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -168,7 +168,7 @@ public: if (! (dragDescription.isVoid() || (dragDescription.isString() && dragDescription.toString().isEmpty()))) { isDragging = true; - owner.startDragAndDrop (e, rowsToDrag, dragDescription, true); + owner.startDragAndDrop (e, rowsToDrag, dragDescription, m->mayDragToExternalWindows()); } } } diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index 224f1d239d..0b607479f8 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -156,6 +156,11 @@ public: */ virtual var getDragSourceDescription (const SparseSet& rowsToDescribe); + /** Called when starting a drag operation on a list row to determine whether the item may be + dragged to other windows. Returns true by default. + */ + virtual bool mayDragToExternalWindows() const { return true; } + /** You can override this to provide tool tips for specific rows. @see TooltipClient */