BR? some macOS menu shortcuts steal keypresses to TextEditor

Not sure if this is a bug or expected behaviour:

  • I have a plugin that also uses the standalone target
  • In this plugin I have a menu item added using addCommandItem, the command item is using a right arrow shortcut key - addDefaultKeypress(juce::KeyPress::rightKey, juce::ModifierKeys::noModifiers)
  • It uses setMacMainMenu to show the menu items
  • This stops the right arrow key working when a TextEditor has focus
  • Other key shortcuts such as . are not stolen and are sent to the TextEditor

This is only happening under macOS, I do not see the same behaviour in Windows (no idea about Linux, but I suspect it would also be immune to this behaviour).

It feels like this might be a bug considering some keypresses are allowed through but others aren’t.

Here is an example AudioProcessorEditor that demonstrates the problem:

Example.zip (2.9 KB)

I looked at a similar-sounding issue a couple of months ago:

If you’re using an older version of JUCE, please can you test with develop and see whether the issue is still present?

I’m afraid it’s still a problem with the latest develop, and in fact using the example I posted it stops the . key from working as a key shortcut entirely. :frowning:

I was hopeful based on the commit message that it would solve the issue, as it seems to describe the problem exactly. Ho hum…

Thanks for your patience. I’ve taken another look at this bug and merged a fix which should work correctly for your use-case:

This appears to work correctly for the test program you provided (thanks for that, having a test-case really speeds up the bug-hunting process!). If you run into any new problems with this change, please let us know.

1 Like