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

NSViewComponentPeer: Avoid processing mouse events from tracking areas

Some plugins (Izotope Relay, some older DPF plugins) use NSTrackingAreas
to handle mouse events, but unprocessed events seemingly get passed up
to outer views. Processing these events was causing unexpected
behaviour. For example, if the cursor entered a plugin view while
dragging a JUCE window border, a mouseEnter event was be generated,
interrupting the drag.

We now check whether mouse events were generated by an NSTrackingArea
which does not belong to the JUCE view, and ignore the event in this
case.
This commit is contained in:
reuk 2021-07-01 12:23:59 +01:00
parent a9d17d860c
commit 630afbda54

View file

@ -636,6 +636,9 @@ public:
void redirectMouseEnter (NSEvent* ev)
{
if (shouldIgnoreMouseEnterExit (ev))
return;
Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate();
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons();
sendMouseEvent (ev);
@ -643,6 +646,9 @@ public:
void redirectMouseExit (NSEvent* ev)
{
if (shouldIgnoreMouseEnterExit (ev))
return;
ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons();
sendMouseEvent (ev);
}
@ -1513,6 +1519,12 @@ private:
static NSView* createViewInstance();
static NSWindow* createWindowInstance();
bool shouldIgnoreMouseEnterExit (NSEvent* ev) const
{
auto* eventTrackingArea = [ev trackingArea];
return eventTrackingArea != nil && ! [[view trackingAreas] containsObject: eventTrackingArea];
}
static void setOwner (id viewOrWindow, NSViewComponentPeer* newOwner)
{
object_setInstanceVariable (viewOrWindow, "owner", newOwner);