1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Mac MainMenu: Allow commands without modifiers to be passed to peer

Ideally, we want to pass shortcut keys to the component to handle, and
only fall back to invoking a menu item if the component was unable to
handle the keyboard event, or if the action was triggered by
clicking/selecting an item in the menu itself. The old implementation
tried to work out whether the action was triggered by a shortcut by
checking the event's characters and modifiers. This method was
inaccurate, because some shortcuts (such as arrow keys) may add
unexpected numpad/function modifier flags.

We now try handling shortcut keys directly in the peer, and pass events
up to the superclass (which will forward them to the main menu) if the
event could not be handled.

This commit also adjusts some Objective-C method signatures to use the
correct string encoding for the BOOL type.
This commit is contained in:
reuk 2021-07-12 19:42:06 +01:00
parent aba8c8c1d3
commit 85226c33d4
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
5 changed files with 38 additions and 41 deletions

View file

@ -157,13 +157,13 @@ private:
static void mainMenuTrackingBegan (id /*self*/, SEL, NSNotification*)
{
if (menuTrackingChangedCallback != nullptr)
(*menuTrackingChangedCallback) (true);
menuTrackingChangedCallback (true);
}
static void mainMenuTrackingEnded (id /*self*/, SEL, NSNotification*)
{
if (menuTrackingChangedCallback != nullptr)
(*menuTrackingChangedCallback) (false);
menuTrackingChangedCallback (false);
}
static void dummyMethod (id /*self*/, SEL) {} // (used as a way of running a dummy thread)