7 Replies Latest reply on Mar 16, 2016 3:54 AM by Toto RoToTO

    Clipboard - Drag and Drop

    Toto RoToTO Level 3


      I would like to know if there is a way to be notified when a clipboard operation has been triggered ?

      (ex: paste from the clipboard - Drag and Drop file, text or custom datas from file system explorer, Photoshop or whatever).


      I took a look at AIClipboardSuite, but I'm a little bit lost.

      I know how to register a new clipboard format handler, how to remove it, how to parse them,.......

      But I was never able to be notified or to catch messages when clipboard operations are made.


      Any help would be appreciated!



        • 1. Re: Clipboard - Drag and Drop
          btempleton1982 Level 2

          Just skimming through the docs, it looks like you need to register a clipboard handler which will then receive messages when clipboard actions occur. Did you SetClipboardOptions?


          It doesn't really look like that is what you need for drag-and-drop operations though.

          • 2. Re: Clipboard - Drag and Drop
            Toto RoToTO Level 3

            I did register my custom format handler. (I did set the clipboard data struct and the clipboard options as well).


            I would like to add to Illustrator a new clipboard format handler, so I could do that:

            From my HTML extension, I could set the clipboard (data) with my custom data and custom format, on start dragging item.

            Then, in my plugin, on drop item action, I want my custom format handler to do the magic! Read the clipboard data and then create arts or whatever.


            I don't if you could do that without using the clipboard!

            • 3. Re: Clipboard - Drag and Drop
              btempleton1982 Level 2

              Did you register message handlers for the clipboard messages?

              • 4. Re: Clipboard - Drag and Drop
                Toto RoToTO Level 3

                I did override the message method in my plugin class to check the caller (kCallerAIClipboard) and the selector (kSelectorAIGoClipboard) but method was never called.

                • 5. Re: Clipboard - Drag and Drop
                  Toto RoToTO Level 3

                  I have found an alternative solution for what I wanted to do!

                  But I still want to know how does the clipboard work!

                  Still looking for answers!

                  • 6. Re: Clipboard - Drag and Drop
                    dnyaneshlb Level 1

                    I am newbie for AI extensions but I have written working DnD extension purely using  extend script and javascript. It works magically smooth.


                    DragStart Event : Set data to be dragged inside event data.


                    DragEnd Event : Give ajax call and download the item (if its is image). Save it locally inside extension folder. Call jsx function to do app specific handling.Let extendscript do its magic. Thats it.


                    I don't have idea if it is possible through clipboard. Above approach is straight enough. Help me know if clipboard approach is even easier.



                    • 7. Re: Clipboard - Drag and Drop
                      Toto RoToTO Level 3

                      Thanks for the tips!



                      Anyway, I finally found an alternative solution to handle drag and drop operations from extensions to Illustrator.

                      I actually did not use the clipboard.

                      I just set the data transfer object on drag start. (extension).

                      On the plugin side, I had to be notified when the scene graph was modified.

                      Finally with a smart move, I was able to retrieve the object dropped  (text/plain with custom informations, uri, metedatas, ....) and do whatever I wanted.

                      (create group, add image, text,......)

                      That's pretty simple and works fine!