Unfortunately, after quite a bit of work this does not appear to fix my problem - though I have managed to disable all commands except the Quit command.
Somehow, the quit command seems to bypass my target manager entirely.
I don’t see how this can happen. JUCEApplication::getAllCommands(), JUCEApplication::getCommandInfo() and JUCEApplication::perform() are never even being called! And neither is my command target. Yet quit is still being called when I press Command-Q when my dialog is up.
It seems as if the Command-Q is entirely being taken care of in Objective C and my code is never called.
I set a break at JUCEApplication::systemRequestedQuit - here’s the stack trace!
#0 0x00395152 in juce::JUCEApplication::systemRequestedQuit at juce_Application.cpp:92
#1 0x0056308d in juce::AppDelegateRedirector::shouldTerminate at juce_mac_MessageManager.mm:63
#2 0x0023a028 in -[JuceAppDelegate_1_54_27_s5d1u applicationShouldTerminate:] at juce_mac_MessageManager.mm:230
#3 0x96e78356 in -[NSApplication _docController:shouldTerminate:]
#4 0x96e77e7c in -[NSDocumentController(NSInternal) _continueTerminationHavingClosedAllDocuments:context:]
#5 0x96e77c5a in -[NSDocumentController(NSInternal) _shouldTerminateWithDelegate:shouldTerminateSelector:]
#6 0x96e77533 in -[NSApplication _shouldTerminate]
#7 0x96e770a5 in -[NSApplication terminate:]
#8 0x96c7ca26 in -[NSApplication sendAction:to:from:]
#9 0x96c7c8d9 in -[NSMenuItem _corePerformAction]
#10 0x96c7c5ca in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
#11 0x96d781c7 in -[NSMenu _performActionWithHighlightingForItemAtIndex:]
#12 0x96d77973 in -[NSMenu performKeyEquivalent:]
#13 0x96d76117 in -[NSApplication _handleKeyEquivalent:]
#14 0x96c6bfe6 in -[NSApplication sendEvent:]
#15 0x96eb721f in -[NSApplication _realDoModalLoop:peek:]
#16 0x96eb6945 in -[NSApplication runModalForWindow:]
#17 0x9714aad3 in -[NSSavePanel runModal]
#18 0x9714414b in -[NSSavePanel runModalForDirectory:file:]
#19 0x00406239 in juce::FileChooser::showPlatformDialog at juce_mac_FileChooser.mm:134
#20 0x00432053 in juce::FileChooser::showDialog at juce_FileChooser.cpp:112
#21 0x00433e68 in juce::FileChooser::browseForFileToOpen at juce_FileChooser.cpp:62
#22 0x0011d45e in rec::gui::dialog::browseForFileToOpen at Dialog.h:28