Why is there example code in the templates? The .glyphsReporter template draws a blue rectangle by default. My understanding was that there is a distinction between samples and templates.
Which of the code or the the methods can or do I have to I remove (like the blue rectangle)?
Couldn’t the whole SDK thing be handled much more cleanly and elegantly by working with a user-defined derived class instead of messing around with the template code (OOP FTW!)? What if the template gets updated? Am I supposed to use a diff tool and work my way though the code?
How can a .glyphsReporter plugin find out whether the Text Tool or the Select Tool is active?
I think it circumvents namespace problems, but I am not sure that is still an issue.
The idea was to facilitate coding for people less experienced in Python scripting. That is why all the read-mes are more like a step-by-step guide. But see below.
We are in the process of discussing exactly that. I will contact you in a DM about it.
Since I made a bunch of reporter plugins I can exactly see Tim’s points. Many of these things are not so important to me anymore, because I got used to them and removing, renaming, etc got quite a habit. But keeping track of the published versions, the version on different computers plus the actual template being updated once in a while also breaks my head sometimes.
If you are interested in more (user/developer) input about the reporter plugins, I’d love to join the discussion.
as well as lastSelectToolIndex but these might not be 100% bulletproof when someone adds his own items to the toolbar. And you might need to initialise Glyphs first with sth like this Glyphs = NSApplication.sharedApplication()
You’re welcome, Tim. It is always good to check the Core as well: Glyphs Reference and very very often I print out the help() for every bits and pieces. There you find probably the most stuff.
Haha, I have been thinking about such a script too, but I have always kept it in my Macro Window. Actually I keep this here in the window, too. Right above the snippet I pasted in the previous post.
Idea: I wonder whether the script should have another EditText for the object you are querying, and you turn the string you receive into a class with NSClassFromString(myObjString)…?
Glyphs.currentDocument.windowController().toolEventDelegate()
# and
Glyphs.currentDocument.windowController().toolDrawDelegate()
This gives you the instance of the current tool. The distinction is important e.g. for the measurement tool. The main drawing stuff will be handled either by the select tool or the text tool (the drawDelegate) and the user input will be handled by the measurement tool (the eventDelegate).
@mekkablue Right, I always oversaw this ComboBox. Updated the script already.
@GeorgSeifert Good to know, looks good. It felt kind of hacky to use the index. Thanks Georg! With this script, hopefully I’ll make fewer mistakes soon
if (Glyphs.currentDocument.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GlyphsToolText")):
# do things for text tool
or
if (Font.parent.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GlyphsToolSelect")):
# do things for selection tool
or:
if (Font.parent.windowController().toolDrawDelegate().isKindOfClass_(NSClassFromString("GSToolSelect")):
# do things for all tools that are subclasses of GSToolSelect (most path editing tools)
to catch even more, use GlyphsPathPlugin, it’s the super class of GSToolSelect
Somehow, I prefer to have a list of all methods (as a simple text file) and then search it using my text editor. Seems more convenient and powerful than a custom tool for the search. (Related: My philosophy is “Sorting is always more powerful than filtering” but we have had that discussion before.)
Yes, I am trying to do the same as View > Show Background via Python.
All the questions I asked in this thread arose while trying to achieve the seemingly simple task of changing the background layer color (which Glyphs does not allow to set, for reasons unknown). So I wrote this plugin (which seems a little complicated for this task). Naturally, the plugin should deactivate the built-in background, otherwise we get this gray line on top of the orange one:
Is there a way to find a list of all the keys I can use for Glyphs.defaults (or, in fact, the keys currently in Glyphs.defaults)? I cannot iterate over it.