mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-06 04:00:08 +00:00
MacOS: Override and implement JuceNSViewClass::updateTrackingAreas()
This change fixes a bug where a fullscreen window would not receive mouseMoved events until the cursor left and then reentered the window's area.
This commit is contained in:
parent
cce38de6cf
commit
edf68d209c
1 changed files with 32 additions and 10 deletions
|
|
@ -40,6 +40,29 @@ using CheckEventBlockedByModalComps = bool (*) (NSEvent*);
|
|||
extern CheckEventBlockedByModalComps isEventBlockedByModalComps;
|
||||
|
||||
//==============================================================================
|
||||
static void resetTrackingArea (NSView* view)
|
||||
{
|
||||
const auto trackingAreas = [view trackingAreas];
|
||||
|
||||
jassert ([trackingAreas count] <= 1);
|
||||
|
||||
for (NSTrackingArea* area in trackingAreas)
|
||||
[view removeTrackingArea: area];
|
||||
|
||||
const auto options = NSTrackingMouseEnteredAndExited
|
||||
| NSTrackingMouseMoved
|
||||
| NSTrackingEnabledDuringMouseDrag
|
||||
| NSTrackingActiveAlways
|
||||
| NSTrackingInVisibleRect;
|
||||
|
||||
const NSUniquePtr<NSTrackingArea> trackingArea { [[NSTrackingArea alloc] initWithRect: [view bounds]
|
||||
options: options
|
||||
owner: view
|
||||
userInfo: nil] };
|
||||
|
||||
[view addTrackingArea: trackingArea.get()];
|
||||
}
|
||||
|
||||
static constexpr int translateVirtualToAsciiKeyCode (int keyCode) noexcept
|
||||
{
|
||||
switch (keyCode)
|
||||
|
|
@ -119,16 +142,7 @@ public:
|
|||
|
||||
[view registerForDraggedTypes: getSupportedDragTypes()];
|
||||
|
||||
const auto options = NSTrackingMouseEnteredAndExited
|
||||
| NSTrackingMouseMoved
|
||||
| NSTrackingEnabledDuringMouseDrag
|
||||
| NSTrackingActiveAlways
|
||||
| NSTrackingInVisibleRect;
|
||||
const NSUniquePtr<NSTrackingArea> trackingArea { [[NSTrackingArea alloc] initWithRect: r
|
||||
options: options
|
||||
owner: view
|
||||
userInfo: nil] };
|
||||
[view addTrackingArea: trackingArea.get()];
|
||||
resetTrackingArea (view);
|
||||
|
||||
notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
|
||||
|
|
@ -1926,6 +1940,7 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
|
|||
{
|
||||
addMethod (@selector (isOpaque), isOpaque);
|
||||
addMethod (@selector (drawRect:), drawRect);
|
||||
addMethod (@selector (updateTrackingAreas), updateTrackingAreas);
|
||||
addMethod (@selector (mouseDown:), mouseDown);
|
||||
addMethod (@selector (mouseUp:), mouseUp);
|
||||
addMethod (@selector (mouseDragged:), mouseDragged);
|
||||
|
|
@ -2009,6 +2024,13 @@ struct JuceNSViewClass : public NSViewComponentPeerWrapper<ObjCClass<NSView>>
|
|||
}
|
||||
|
||||
private:
|
||||
static void updateTrackingAreas (id self, SEL)
|
||||
{
|
||||
sendSuperclassMessage<void> (self, @selector (updateTrackingAreas));
|
||||
|
||||
resetTrackingArea (static_cast<NSView*> (self));
|
||||
}
|
||||
|
||||
static void mouseDown (id self, SEL s, NSEvent* ev)
|
||||
{
|
||||
if (JUCEApplicationBase::isStandaloneApp())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue