Still failing to select a menu in FINALE with modifier keys

I had a previous request about this issue that found no solution:

I noticed @peternlewis in another topic talk about software that didn't properly obey MAC modifier key behaviour:

But one of Finale's original coders has confirmed that the modifier key code in Finale does indeed interrogate the current event:

uint32_t _cocoalink_GetCurrentModifierKeys()
{
    const NSUInteger flags = [[NSApp currentEvent] modifierFlags];
    const FLAG_32 shiftkey = (flags & NSEventModifierFlagShift) ? __FCUserWindow::CMDMODKEY_SHIFT : 0;
    const FLAG_32 fnkey = (flags & NSEventModifierFlagFunction) ? __FCUserWindow::CMDMODKEY_FUNCTION : 0;
    const FLAG_32 altkey = (flags & NSEventModifierFlagOption) ? __FCUserWindow::CMDMODKEY_ALT : 0;
    const FLAG_32 ctrlkey = (flags & NSEventModifierFlagControl) ? __FCUserWindow::CMDMODKEY_CTRL : 0;
    const FLAG_32 cmdkey = (flags & NSEventModifierFlagCommand) ? __FCUserWindow::CMDMODKEY_COMMAND : 0;
    
    return shiftkey | fnkey | altkey | ctrlkey | cmdkey;
}

Having tried everything we could imagine from my first post, can anybody guess at why Finale software can correctly identify key modifiers with a menu item selected manually with a mouse, but can't detect them when a menu is selected with KM?

How are you selecting the menu?

The Select a Menu Item action selects the menu via the accessibility API. So there may not even be a real “current event” at that point to process, since the accessibility API is not part of the event queue. If so, then Finale’s behaviour has accessibility implications which they may want to think about.

That said, the only options I can suggest are:

or

or, desperation

If none of them work, then I'm out of ideas.

Thank you for such a quick, thorough and thoughtful reply!

Had already tried the first option and the other two sadly also don't work. I'll keep pondering, but if you can't think of a fourth solution then I doubt anybody can!

I thought this might interest you, @peternlewis.

I revisited this issue (urged by the veteran Finale scripter) and your 3rd option WORKS! Turns out that Finale needs a MOUSE-UP WITH MODIFIER event, at least to pass modifier key information through to the plug-in (via PDK) with a menu. Several methods work to get to the required sub-menu item, but there must be a click on that sub-menu followed by a RELEASE with modifier.

This will be valuable information to a small band of dedicated Finale users who use KM for all their GUI needs. I've attached a pic of the macro and the macro itself - customised for one of my tasks.


Finale OPTION click menu.kmmacros (73.3 KB)

1 Like

I might have found another solution..

It's still a hack, but it's working here.

Program a shortcut to the menu item you're targeting using:
System Preferences > Keyboard > Shortcuts > App Shortcuts

Choose a Key Combination that you're unlikely to use for anything else
and BE SURE IT INCLUDES THE OPTION KEY(or whatever modifier you need)

By including the Modifier key in the Key Combination,
Finale will be tricked into thinking the Modifier is down when the menu item is selected.

This new System Preference shortcut can now be called by KM with a Type a Keystroke action.

The downside is you lose a Hotkey for each of these you program,
and the way RGP is trending the number of modifier/scripts will increase in the near future.

Hey @MikeMcC. It's ages since I've used Apple's own keyboard shortcuts instead of KM, and you're right - this works! The downside is coordinating the System shortcuts with the KM ones (I use around 500 of them on Finale) and keeping them all intelligently referenced and cooperating with Finale's own builtin shortcuts. (KM palettes are such a brilliant way to organise groups of related activities).

About a year ago I found 3 other ways to achieve the modifier menu action, and the most convenient of these within KM is the AppleScript method outlined here: https://carlvine.com/cgi-bin/index.cgi?cv=km_opt

It all lives inside KM and only requires adding the specific requisite menu name in step two. As a side note, RGP himself envisaged modifier activation linked specifically to optional modeless operation, though of the 8 or so main contributors to the FinaleLua.com repository, he's the only one to use it like that. I always use it (now) as a Repeat Last Action option to avoid an extra (redundant) menu item.