Sorry if I’m misunderstanding how this works, but I have a blank GUI Application and am expecting Command + W to close the window (or call closeButtonPressed()) on macOS but it does not. It doesn’t seem to matter if the window has keyboard focus or not. Any idea why that doesn’t work?
I can see in the DocumentWindow code where it looks like this functionality was attempted:
if (auto* b = getCloseButton())
{
#if JUCE_MAC
b->addShortcut (KeyPress ('w', ModifierKeys::commandModifier, 0));
Well, in the projucer we just do it like all our other keys - search for “CommandIDs::closeDocument” and you’ll see how we did it there.
Or if you’re not using the ApplicationCommand system, you could just catch the keypress in your top level component’s keyPressed method and close the window directly.