Alternative menuName for plug-in

By developing a Multiple Master font family, I needed so many times to duplicate nodes but in all Masters simultaneously.

Few days ago, I discover that “Duplicate Nodes” plugin actually allow to do this, but the function was a bit hidden and only explained in documentation. So I tried to add some alternative menuName for display more explanatory names when ALT or SHIFT get pressed, something like this:

if optionKeyPressed:
return Glyphs.localize({
‘en’: ‘Duplicate Nodes (All Masters)’,
‘de’: ‘Punkte verdoppeln (Alle Master)’,
‘fr’: ‘Dupliquer nœuds (Toutes les masters)’,
‘es’: ‘Duplicar nodos (Todos los masters)’,
‘pt’: ‘Duplicar nodos (Todos os masters)’,
‘it’: ‘Duplica nodi (Tutti i master)’,
})
elif shiftKeyPressed:
return Glyphs.localize({
‘en’: ‘Duplicate Nodes (Apart)’,
‘de’: ‘Punkte verdoppeln (Getrennt)’,
‘fr’: ‘Dupliquer nœuds (Séparément)’,
‘es’: ‘Duplicar nodos (Separados)’,
‘pt’: ‘Duplicar nodos (Separados)’,
‘it’: ‘Duplica nodi (Separati)’,
})
else:
return self.menuName

but didn’t work.

So I just replaced
from: ‘en’: 'Duplicate Nodes’,
to: ‘en’: ‘Duplicate Nodes (+ALT to Masters +SHIFT apart)’,

simple but at least reminds me what each modifier do.

the question is, there’s any way to make an alternative menuName to actually visually be switched in Glyphs Menu?

You need to add the menus yourself. You can’t use the convenience method. Search for NSMenuItem in your Repositories folder to find examples on where and how to do this.

1 Like

I found not even a single script or plugin that really do what I expected to do. It seems that switch displayed menuName is reserved for internal usage only, or at least I couldn’t solved it.

There was a similar question here: How to listen for whether the option key is pressed in the right-click menu? - #2 by FlorianPircher

There are many plugins that add a menu item. One example: Arrange-Windows/ArrangeWindows.glyphsPlugin/Contents/Resources/plugin.py at ff44224492574c12ff8ad82db7a825189d92b0f9 · Mark2Mark/Arrange-Windows · GitHub

1 Like