Shortcut to Connect Nodes

Is it possible to assign a keyboard shortcut (maybe Cmd+Something) to perform Connect Nodes? I am asking since Connect Nodes is not present in the menu items and there is no way assign that way.

You can assign a keyboard shortcut to anything you want if you go in System Preferences. Go in System Preferences > Keyboard > Shortcuts > App Shortcuts then add a shortcut for Glyphs.app by entering the exact name of the menu item you want.

I tried though and it seems it only works with menu bar items and not with contextual menu items. You can use reconnect nodes instead. It doesn’t do the exact same thing but it works as a shortcut since it is also available in the Paths menu.

@GeorgSeifert Maybe you could add the rest of the contextual options of the edit view in the “Other” section of the paths menu. This way we could add shortcuts to anyone one of them. I don’t know if it would be overcrowded though. Just a thought.

1 Like

@ jeremie - That is what I meant by “not present in the menu items”

@ georg - So the question still holds, is there a way to do it?

Copy the following code in a file and save it to the Scripts folder. This will generate a menu item with the name "
“Connect Nodes” and that can be used to add the keyboard shortcut in system preferences as described above.

#MenuTitle: Connect Nodes
# encoding: utf-8
from Foundation import NSSelectorFromString
print Font.currentTab.graphicView().tryToPerform_with_(NSSelectorFromString("connectNodes"), None)
2 Likes

You could write a simple script and that way, add it to the menu, and thus have a menu entry you can assign short cut to. This is the code you need:

Layer = Glyphs.font.selectedLayers[0] # frontmost font
sel = Layer.selection
if len(sel) == 2 and type(sel[0]) == GSNode and type(sel[1]) == GSNode:
	Layer.connectPathsWithNode_andNode_(sel[0],sel[1])
2 Likes

We did answer the same question at the same time :wink:

Thank you, guys. This is excellent!

1 Like