mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Added a workaround in OSX so that plugin windows inside modal host windows can open popups
This commit is contained in:
parent
8c6ef0b0e4
commit
ea07c5b2b0
1 changed files with 44 additions and 34 deletions
|
|
@ -844,15 +844,15 @@ public:
|
|||
|
||||
bool sendModalInputAttemptIfBlocked()
|
||||
{
|
||||
Component* const modal = Component::getCurrentlyModalComponent();
|
||||
|
||||
if (modal != nullptr
|
||||
&& insideToFrontCall == 0
|
||||
&& (! getComponent().isParentOf (modal))
|
||||
&& getComponent().isCurrentlyBlockedByAnotherModalComponent())
|
||||
if (Component* modal = Component::getCurrentlyModalComponent())
|
||||
{
|
||||
modal->inputAttemptWhenModal();
|
||||
return true;
|
||||
if (insideToFrontCall == 0
|
||||
&& (! getComponent().isParentOf (modal))
|
||||
&& getComponent().isCurrentlyBlockedByAnotherModalComponent())
|
||||
{
|
||||
modal->inputAttemptWhenModal();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -865,9 +865,15 @@ public:
|
|||
|
||||
bool canBecomeMainWindow()
|
||||
{
|
||||
Component* owner = &juce::ComponentPeer::getComponent();
|
||||
return dynamic_cast<ResizableWindow*> (&component) != nullptr;
|
||||
}
|
||||
|
||||
return dynamic_cast<ResizableWindow*> (owner) != nullptr;
|
||||
bool worksWhenModal() const
|
||||
{
|
||||
// In plugins, the host could put our plugin window inside a modal window, so this
|
||||
// allows us to successfully open other popups. Feels like there could be edge-case
|
||||
// problems caused by this, so let us know if you spot any issues..
|
||||
return ! JUCEApplication::isStandaloneApp();
|
||||
}
|
||||
|
||||
void becomeKeyWindow()
|
||||
|
|
@ -1408,9 +1414,9 @@ private:
|
|||
int NSViewComponentPeer::insideToFrontCall = 0;
|
||||
|
||||
//==============================================================================
|
||||
struct JuceNSViewClass : public ObjCClass <NSView>
|
||||
struct JuceNSViewClass : public ObjCClass<NSView>
|
||||
{
|
||||
JuceNSViewClass() : ObjCClass <NSView> ("JUCEView_")
|
||||
JuceNSViewClass() : ObjCClass<NSView> ("JUCEView_")
|
||||
{
|
||||
addIvar<NSViewComponentPeer*> ("owner");
|
||||
|
||||
|
|
@ -1432,8 +1438,10 @@ struct JuceNSViewClass : public ObjCClass <NSView>
|
|||
addMethod (@selector (otherMouseUp:), mouseUp, "v@:@");
|
||||
addMethod (@selector (scrollWheel:), scrollWheel, "v@:@");
|
||||
addMethod (@selector (magnifyWithEvent:), magnify, "v@:@");
|
||||
addMethod (@selector (acceptsFirstMouse:), acceptsFirstMouse, "v@:@");
|
||||
addMethod (@selector (acceptsFirstMouse:), acceptsFirstMouse, "c@:@");
|
||||
addMethod (@selector (frameChanged:), frameChanged, "v@:@");
|
||||
addMethod (@selector (wantsDefaultClipping:), wantsDefaultClipping, "c@:");
|
||||
addMethod (@selector (worksWhenModal), worksWhenModal, "c@:");
|
||||
addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:");
|
||||
addMethod (@selector (keyDown:), keyDown, "v@:@");
|
||||
addMethod (@selector (keyUp:), keyUp, "v@:@");
|
||||
|
|
@ -1503,23 +1511,25 @@ private:
|
|||
waitUntilDone: NO];
|
||||
}
|
||||
|
||||
static void asyncMouseDown (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseDown (ev); }
|
||||
static void asyncMouseUp (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseUp (ev); }
|
||||
static void mouseDragged (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseDrag (ev); }
|
||||
static void mouseMoved (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseMove (ev); }
|
||||
static void mouseEntered (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseEnter (ev); }
|
||||
static void mouseExited (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseExit (ev); }
|
||||
static void scrollWheel (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMouseWheel (ev); }
|
||||
static void magnify (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMagnify (ev); }
|
||||
static void copy (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectCopy (s); }
|
||||
static void paste (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectPaste (s); }
|
||||
static void cut (id self, SEL, NSObject* s) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectCut (s); }
|
||||
static void asyncMouseDown (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseDown (ev); }
|
||||
static void asyncMouseUp (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseUp (ev); }
|
||||
static void mouseDragged (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseDrag (ev); }
|
||||
static void mouseMoved (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseMove (ev); }
|
||||
static void mouseEntered (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseEnter (ev); }
|
||||
static void mouseExited (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseExit (ev); }
|
||||
static void scrollWheel (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMouseWheel (ev); }
|
||||
static void magnify (id self, SEL, NSEvent* ev) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMagnify (ev); }
|
||||
static void copy (id self, SEL, NSObject* s) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectCopy (s); }
|
||||
static void paste (id self, SEL, NSObject* s) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectPaste (s); }
|
||||
static void cut (id self, SEL, NSObject* s) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectCut (s); }
|
||||
|
||||
static BOOL acceptsFirstMouse (id, SEL, NSEvent*) { return YES; }
|
||||
static BOOL wantsDefaultClipping (id, SEL) { return YES; } // (this is the default, but may want to customise it in future)
|
||||
static BOOL worksWhenModal (id self, SEL) { if (NSViewComponentPeer* p = getOwner (self)) return p->worksWhenModal(); return NO; };
|
||||
|
||||
static void drawRect (id self, SEL, NSRect r) { if (NSViewComponentPeer* const p = getOwner (self)) p->drawRect (r); }
|
||||
static void frameChanged (id self, SEL, NSNotification*) { if (NSViewComponentPeer* const p = getOwner (self)) p->redirectMovedOrResized(); }
|
||||
static void viewDidMoveToWindow (id self, SEL) { if (NSViewComponentPeer* const p = getOwner (self)) p->viewMovedToWindow(); }
|
||||
static void drawRect (id self, SEL, NSRect r) { if (NSViewComponentPeer* p = getOwner (self)) p->drawRect (r); }
|
||||
static void frameChanged (id self, SEL, NSNotification*) { if (NSViewComponentPeer* p = getOwner (self)) p->redirectMovedOrResized(); }
|
||||
static void viewDidMoveToWindow (id self, SEL) { if (NSViewComponentPeer* p = getOwner (self)) p->viewMovedToWindow(); }
|
||||
|
||||
static BOOL isOpaque (id self, SEL)
|
||||
{
|
||||
|
|
@ -1711,12 +1721,12 @@ private:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
static NSDragOperation draggingEntered (id self, SEL s, id <NSDraggingInfo> sender)
|
||||
static NSDragOperation draggingEntered (id self, SEL s, id<NSDraggingInfo> sender)
|
||||
{
|
||||
return draggingUpdated (self, s, sender);
|
||||
}
|
||||
|
||||
static NSDragOperation draggingUpdated (id self, SEL, id <NSDraggingInfo> sender)
|
||||
static NSDragOperation draggingUpdated (id self, SEL, id<NSDraggingInfo> sender)
|
||||
{
|
||||
if (NSViewComponentPeer* const owner = getOwner (self))
|
||||
if (owner->sendDragCallback (0, sender))
|
||||
|
|
@ -1725,29 +1735,29 @@ private:
|
|||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
static void draggingEnded (id self, SEL s, id <NSDraggingInfo> sender)
|
||||
static void draggingEnded (id self, SEL s, id<NSDraggingInfo> sender)
|
||||
{
|
||||
draggingExited (self, s, sender);
|
||||
}
|
||||
|
||||
static void draggingExited (id self, SEL, id <NSDraggingInfo> sender)
|
||||
static void draggingExited (id self, SEL, id<NSDraggingInfo> sender)
|
||||
{
|
||||
if (NSViewComponentPeer* const owner = getOwner (self))
|
||||
owner->sendDragCallback (1, sender);
|
||||
}
|
||||
|
||||
static BOOL prepareForDragOperation (id, SEL, id <NSDraggingInfo>)
|
||||
static BOOL prepareForDragOperation (id, SEL, id<NSDraggingInfo>)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
static BOOL performDragOperation (id self, SEL, id <NSDraggingInfo> sender)
|
||||
static BOOL performDragOperation (id self, SEL, id<NSDraggingInfo> sender)
|
||||
{
|
||||
NSViewComponentPeer* const owner = getOwner (self);
|
||||
return owner != nullptr && owner->sendDragCallback (2, sender);
|
||||
}
|
||||
|
||||
static void concludeDragOperation (id, SEL, id <NSDraggingInfo>) {}
|
||||
static void concludeDragOperation (id, SEL, id<NSDraggingInfo>) {}
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue