2 Replies Latest reply on Sep 26, 2017 8:18 PM by ov-ov

    How to implement preview option in plugin with HTML UI?

    ov-ov Level 1

      Hi guys,

       

      I work on the plugin that somehow changes the selected artwork. Let's say that it simply sets the fill color of all the selected paths to the user selected value. I added it to the "Object" menu and then user clicks my item, I display a nice HTML UI (using CSXS) window. The UI part asks for a color, then sends it to my C++ code that does the job.

       

      So far so good, but how do I implement that preview checkbox that you may see in other built-in Illustrator dialogs? Any change that I make to the scene is wrapped to its own undo record and if I select some colors, I'll end up with a bunch of undo/redo records in my document. More, if I have some redo records before I call my plugin - they will be lost

       

      The built-in dialogs with preview somehow manage to keep the undo/redo stack intact, but still display preview.

       

      I tried to keep a single app context through the lifetime of my UI window using push/pop of app contexts or by suspending and resuming it when needed, but it doesn't work. It looks like undo records are created for each plugin call and with that HTML UI I get more than just a single call, so get many contexts and many undo records...

       

      So the question is: what is the best practice of implementing HTML UI with preview that doesn't alter undo/redo stack?

       

      Thank you.