Is it possible to use the same glyph-chooser dialog as Add Component from a Python script, to make the user select a glyph? That would be very handy! I am thinking of something like GetOpenFile() but for a glyph.
I’ll see how I can add it to the wrapper. Here is the full code:
GSSelectGlyphsDialogController = objc.lookUpClass("GSSelectGlyphsDialogController")
selectGlyphPanel = GSSelectGlyphsDialogController.alloc().init()
selectGlyphPanel.setTitle_("Find Glyphs")
Master = Font.masters[0] # Pick with master you are interested in, e.g., currentTab.masterIndex
selectGlyphPanel.setMasterID_(Master.id)
selectGlyphPanel.setContent_(list(Font.glyphs))
PreviousSearch = Glyphs.defaults["PickGlyphsSearch"]
if PreviousSearch and len(PreviousSearch) > 0:
selectGlyphPanel.setSearch_(PreviousSearch)
if selectGlyphPanel.runModal():
Glyphs.defaults["PickGlyphsSearch"] = selectGlyphPanel.glyphsSelectSearchField().stringValue()
for glyph in selectGlyphPanel.selectedGlyphs():
print glyph
3 Likes
Excellent! Works very well. Btw, would it be possible to detect whether the OK button was shift-clicked (or cmd or ctrl)?
Thanks!