I'm a Windows developer developing a Cocoa-based plugin for a MacOS host application (Premiere Pro). At certain times, the host blockingly calls into my plugin callback function, at which time I'm supposed to show a modal dialog, only returning once the dialog is dismissed.
I've already managed to put up the modal dialog, nicely parenting it to the host's main window via:
// Get this from the host
NSWindow* parentWindowHandle = ...;
// Create this one myself, or rather have the Juce framework create it for me
NSWindow* ourWindowHandle = ...;
// Connect the two
[parentWindowHandle addChildWindow:ourWindowHandle ordered:NSWindowAbove];
This works nicely; my dialog is always on top of the host, and the host's main window is disabled.
But...
The host's menu is still active at that time. And worse, it is even responsive as well, which allows the user to start host functionality while my modal dialog is up, which ultimately results in their modal open next to mine and a certain hang (forever spinning beachball).
I realize it's quite possible I'm attacking this the wrong way being a Windows developer and all, but then again maybe this is just an oversight in the host app?
And an almost certainly related question which might be a clue as well: Copy/Paste via the keyboard just doesn't work in text boxes in my plugin modal dialogs, right until I manually click the host's "Edit" menu open, after which keyboard shortcut pasting works again. For the rest of the host's lifetime no less, even when my dialog gets dismissed and a new one created later on.
EDIT
I've tried [[NSApplication sharedApplication] runModalForWindow: myDialogWindow]
as advertized in the linked question, but it blocks right on that line. Seems legit, since it should enter a modal loop. However, my Cocoa window is created for me by a GUI framework (Juce; it's a multiplatform project), so I have no control over how the messages for the window are handled. So I guess the above way is unusable in my situation?
addChildWindow
function does make my dialog a modal dialog wrt the parent, if only for it's menu still being active and responsive, so there's prob. a better way to handle this on OSX :) – Carl Colijn[[NSApplication sharedApplication] runModalForWindow: myDialogWindow]
, but it only leads to lockups... Furthermore, I'm using a GUI framework (Juce) for the windowing, and it in turn already does it's own modal loop (a CFRunLoop -- sp?) and handling Cocoa messages, so I guess it is incompatible with calls torunModalForWindow
which blocks on the spot. – Carl Colijn[[NSApplication sharedApplication] mainMenu]
and tweaking that is Truly Evil? I saw menus are disabled automatically by unassigning handlers to items, so I'd have to loop over all menu items and assign nil handlers to them, later restoring them -- seems like quite a dirty hack, if it even works that is. – Carl Colijn