abynim/sketch-toolbar-item

When is ValidateToolbarItem called?

miked1ck opened this issue · 2 comments

I'm having a hard time getting ValidateToolbarItem to run:

Manifest.js

"handlers": {
   "run": "openKit",
   "ValidateToolbarItem": "validateToolbarItem"
}

my-command.js

export function validateToolbarItem(context) {
  console.log('Hey!', context)
}

BTW, awesome plugin. Thank you for it!

Your implementation of validateToolbarItem should be called by Sketch whenever it internally validates all toolbar items (for example, on selection change), but it does so only if the corresponding item is actually in the toolbar.

Please use this only if required though, since having to spawn a JS context on every selection change slows down Sketch quite a bit. I had added this feature to see if it was possible, but later realized that on slower machines it does cause a visible lag.