AlertWindow focus issue

My app has a safe mode, which disables the gui, unless a special key command is pressed. I implemented this by creating a subclass AlertWindow with no buttons, and in the constructor I grab keyboard focus and in keyPressed I check if the key equals the special key, and if it is, I exit the modal state.

This works fine on the pc, but on the mac, if i enter the modal state in a buttonClicked callback, the grab keyboard focus fails and my alert window doesn’t get keypresses, even though it’s modal.

I’ll check this out and get it sorted for next time, but wouldn’t it have been easier just to use a normal AlertWindow containing a button with the appropriate key shortcut?