I've been trying to use Juce in an AE plug-in primarily to create a Modal (I know, I know it's bad, but more on that later) window in OS X, but I'm running into the following issues.
1. runModal() is not truly modal:
Whenever I create a new Dialog Window with the following code, the resultant window isn't truly modal. The Menubar is still active and any keyboard shortcuts (like Cmd-C/Cmd-V) are still applied to the host window in the background. When I select the label and edit it, only Cmd-V works, that too I'm assuming only because the paste stack is empty/greyed out in the menu bar before starting the window.
NSWindow* mainWindow = [[NSApplication sharedApplication] keyWindow]; DialogWindow::LaunchOptions launch_optns; launch_optns.dialogTitle = "Test Window"; launch_optns.dialogBackgroundColour = Colour(128,128,128); launch_optns.content.setOwned(new MainComponent); launch_optns.content->setSize(640, 480); launch_optns.content->addToDesktop(0,[mainWindow contentView]); launch_optns.runModal();
Also, interestingly launchAsync() has the exact similar problem even though now mouse events are no longer blocked.
2. Force Modal:
Now, after a bit of tinkering, I've made the Juce window 'key' using some Cocoa code and this time forcibly making it Modal in Cocoa.
DialogWindow* mdlDlg = launch_optns.launchAsync(); NSWindow* modWin = [(NSView*)mdlDlg->getWindowHandle() window]; [modWin setParentWindow:mainWindow]; [modWin makeKeyAndOrderFront:nil]; [NSApp runModalForWindow:modWin];
Now, the modal part is achieved successfully, but none of the keyboard shortcuts work. I can type letters in the label form, but can't copy/cut/paste in it.
So I'm wondering what is the solution for this problem? Juce seems to handle plug-in bundles quite effectively, so not sure what's the issue here. It would be really cool if someone could help to get this working, since I'm really interested to use Juce in my main projects!
P.S: Why Modal? Right now the AE SDK is very limited and modal windows are the only way to go, if one wanst to prevent render calls during active UI changes, AFAIK.