Remove temporary rectangle from Artboard

I need to remove a rectangle from an Artboard when the Artboard stops being selected.

Is there anyway to edit the document without the user triggering some UI event directly on the panel?


  1. If an Artboard is selected the user can specify height, width, x, and y values.
  2. Create a rectangle and display within Artboard at specified size and origin.
  3. If the Artboard stops being selected (or plugin panel is closed) remove the rectangle.

Current Setup
I’m detecting that the Artboard has lost focus (not selected anymore) via the update function attached to my panel. But when I try to removeFromParent I get the error;

  • Plugin Error: Panel plugin edits must be initiated from a supported UI event.


  • This is a panel plugin.
  • I am using application.editDocument.
  • I’m successfully creating and adding the rectangle to the Artboard.
    • When the user specifies a size/origin value from the panel.
1 Like

Shouldn’t any user interaction (i.e. clicking of the selected Artboard), be a supported UI event?

Hi @mudlabs,

There currently isn’t any way to edit the document without a “real” UI event, i.e., the user performing an action in a plugin. The thing is that if, e.g., deselecting an artboard, were a supported UI event, this would basically defeat one of the benefits, i.e., restrictions for how a plugin can “destroy” the document without specific interaction. As selecting and deselecting nodes is a common thing in the user flow, you’d basically have a lot of “entry points” to do whatever you want with the plugin :slightly_smiling_face:.

Another thing is that when the user deselects the artboard, you might get problems with the edit context when trying to remove that rectangle. For example, if the user selected some node inside another artboard, the edit context would then be there and you’d no longer be able to access the rectangle in your artboard.

All in all, I therefore believe that it currently isn’t possible to achieve your requirements.

I hope this helps (somewhat :wink:),