sketch-toolbar-item icon indicating copy to clipboard operation
sketch-toolbar-item copied to clipboard

When is ValidateToolbarItem called?

Open miked1ck opened this issue 5 years ago • 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)
}

miked1ck avatar Sep 27 '19 23:09 miked1ck

BTW, awesome plugin. Thank you for it!

miked1ck avatar Sep 27 '19 23:09 miked1ck

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.

abynim avatar Apr 01 '20 08:04 abynim