mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +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
94dcad52d0
commit
c1a38b0cfc
1 changed files with 32 additions and 10 deletions
|
|
@ -41,6 +41,29 @@ namespace juce
|
|||
{
|
||||
|
||||
//==============================================================================
|
||||
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)
|
||||
|
|
@ -121,16 +144,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];
|
||||
|
||||
|
|
@ -1843,6 +1857,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);
|
||||
|
|
@ -1925,6 +1940,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