Alternate Menu Entry

In a plugin, I try to have an alternative Menu Entry when the Option key is pressed.

newMenuItem = NSMenuItem(, self.callbackA)
newMenuItemAlt = NSMenuItem(self.nameAlt, self.callbackB)
newMenuItemAlt.setAlternate_(True) # A Boolean value that marks the menu item as an alternate to the previous menu item.[SCRIPT_MENU].append(newMenuItem)[SCRIPT_MENU].append(newMenuItemAlt)

What is wrong that it doesn’t appear with the option key? When I remove the setAlternate_line, both entries appear. Do I have to pass the other menu item as a parameter? I tired, doesn’t work, too.

When I put it into the [WINDOW_MENU] instead (where I need it to be later), it overwrites the “Kerning” Menu entry there. And when I hit the option key in that case, the “Kerning” entry appears instead of my entry. This seems to be a bug with the[SCRIPT_MENU].append() method?!
I solved this issue by adding a separator. So that’s not too important, just maybe good to know for you.

You might try to add newMenuItemAlt.setKeyEquivalentModifierMask_(NSAlternateKeyMask)

1 Like

Yeaaaah! That is it! Thanks so much. That formerly used modifier initWithTitle_action_keyEquivalent_ got lost in the new API variant. But you made it way clearer now, I like to be explicit here and set things one by one like you suggested here. :raised_hands:

1 Like

Here’s the result added to the Plugin Manager …

1 Like

The init method has a key equivalent, and then we set a modifier. That are two different things.

Oh, I thought keyEquivalentModifierMask was one thing.