ily1437
So that's the problem I mentioned earlier, that the InsertSymbol.finish
action is triggered when you begin inserting a symbol rather than after a symbol has been successfully added. Will be nice if this could be fixed in Sketch itself.
As a workaround, in the InsertSymbol.finish
handler we save a true/false flag in NSUserDefaults
that a symbol instance is about to be added. When an instance is added, the SelectionChanged.finish
handler gets triggered since Sketch will automatically select the symbol instance that has been added. Here we check the flag again to see if a symbol instance was being added, and take further action as required.
It's totally a hack so I would not recommend actually using this in a plugin that you might release publicly. Also, doing anything on SelectionChanged
will slow down Sketch because it needs to initiate a new JS context every time.
Is there a way to insert a Group/Layer(MSSymbolInstance) like this ?
I mean using code to create a Group with many SymbolInstance, and use action to insert it into document
I recently added this functionality in Runner so it's definitely possible, but not with this method. I'm not sure how to make it work using JavaScript though.