1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

NSViewComponentPeer: Ignore mouseDragged messages during DnD operations

Prior to this change trying to drag and drop a file onto a target inside
a Viewport could cause hectic scrolling events.
This commit is contained in:
attila 2025-04-11 11:58:29 +02:00 committed by Attila Szarvas
parent 0943197e23
commit 087f915595

View file

@ -744,6 +744,12 @@ public:
void redirectMouseDrag (NSEvent* ev)
{
// Very rarely we seem to receive mouseDragged messages in between draggingEntered and draggingExited
// messages. If our drag target is in a viewport, it can cause it to scroll around, so we ignore these
// stray mouseDragged messages.
if (draggingActive)
return;
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withFlags (getModifierForButtonNumber ([ev buttonNumber]));
sendMouseEvent (ev);
}
@ -1472,6 +1478,12 @@ public:
BOOL sendDragCallback (bool (ComponentPeer::* callback) (const DragInfo&), id <NSDraggingInfo> sender)
{
if (callback == &NSViewComponentPeer::handleDragMove)
draggingActive = true;
if (callback == &NSViewComponentPeer::handleDragExit || callback == &NSViewComponentPeer::handleDragDrop)
draggingActive = false;
NSPasteboard* pasteboard = [sender draggingPasteboard];
NSString* contentType = [pasteboard availableTypeFromArray: getSupportedDragTypes()];
@ -1732,6 +1744,7 @@ public:
bool windowRepresentsFile = false;
bool isAlwaysOnTop = false, wasAlwaysOnTop = false, inBecomeKeyWindow = false;
bool inPerformKeyEquivalent = false;
bool draggingActive = false;
String stringBeingComposed;
int startOfMarkedTextInTextInputTarget = 0;