I had the functionality of being able to select everything between two selected nodes by pressing Command+Option+Shift+; This function didn’t survive my migration to a new mac, and I want it back but I can’t for the life of me remember which Plugin it was. I’m pretty sure it was an additional or minor feature of a plugin, and that it possibly wasn’t installed using the plugin manager.
Just with the mouse pointer, then the shortcut would select everything between then two initially selected nodes. Sometimes it would take the wrong way around, but they you just invert it.
def select_all_nodes_between_selected_nodes():
selected_nodes = [selection for selection in Layer.selection if type(selection) == GSNode] # get all the selected nodes
if len(selected_nodes) >= 2: # if at least two nodes are selected
parent_path = selected_nodes[0].parent
for selected_node in selected_nodes: # check whether all nodes belong to the same path
if selected_node.parent != parent_path:
return # if not, cancel
node_indices = [parent_path.nodes.index(selected_node) for selected_node in selected_nodes] # collect the indices of all selected nodes
nodes_in_between = [node for node in parent_path.nodes[min(node_indices):max(node_indices) + 1]] # get the nodes for all indices between the smallest and biggest selected node index
for node in nodes_in_between:
node.selected = True # select all nodes in between
select_all_nodes_between_selected_nodes()
Edit: You can now find it in my scripts, also available in the plugin manager.
Got it working, and the script works. Unfortunately the keyboard shortcuts in Glyph are still broken, so I couldn’t get Glyphs to accept my usual Cmd+Opt+: combo.
@SCarewe If you want to make the script even better, then tag on a functionality that inverts the selection – but only of the outline that is currently selected – when the script is run again after the first run. Meaning, the inverse selection is not of everything else in the glyph, but only the inverse of whatever outline was selected.
That will be difficult/not possible to implement, as the script cannot know whether you selected the nodes or the nodes were selected by the script. I would like to avoid writing a userData entry for each node saving this.
But I do of course see the merit of this functionality. Would a modifier key work? As in, holding down Option while running the script selects the inverse?
This is true, and very annoying. For the time being, at least what works for me is going into the Mac system settings and adding a keyboard shortcut in Keyboard > Keyboard Shortcuts > App Shortcuts. Add Glyphs 3 as an app in the list, then write the exact menu title of the script as it appears in Glyphs.
What modifier key would make sense to you? I would use Option, but I see you are already using Option in your preferred keyboard shortcut, as well as Shift in order to type :. I don’t think Control makes sense here, would you be ok with adapting your preferred keyboard shortcut?
I suppose Cmd+Opt+; could be the one way, and Cmd+Opt+: the other. That would work fine. I’m not married to the shortcuts, they were just the ones that happened to be hardcoded in the unknown original plugin.
That wouldn’t be a modifier key, but two separate keyboard shortcuts, essentially for two different scripts.
There needs to be a way of running the script from the menu by clicking it and holding down a modifier key, which is also compatible with a keyboard shortcut.
As an alternative, you might want a script that inverts the selection for all selected paths. That way, you run the select-in-between-script first, and if you wanted the inverse selection, run this script afterwards:
selected_paths = set([x.parent for x in Layer.selection if type(x) == GSNode])
for path in selected_paths:
for node in path.nodes:
node.selected = not node.selected
This script might also proof useful in other contexts.