4 Replies Latest reply on Sep 12, 2013 10:42 AM by Harbs.

    Drag and drop to apply color to art.

    poortip87 Level 1

      Hi All,

       

      I am designing a panel for Illustrator CS6 that displays colors in a datagrid as follows,

      [Color] [Color_Name]

       

      I want to be able to apply color to any art by using the drag-n-drop from the panel to the document. Is it possible that I am able to detect the art on which the color was dropped so that I can apply the color?

       

      Thanks!

        • 1. Re: Drag and drop to apply color to art.
          Harbs. Level 6

          The only way I can see to do something like that would be to write an Illustrator plugin which tracks the mouse interactions and then fires an event to be handled by the extension.

           

          HTH,

          Harbs

          • 2. Re: Drag and drop to apply color to art.
            poortip87 Level 1

            Thanks for the reply Harbs! I am okay with writing a plugin which works with the extension.. My question is, will I be able to get the art object based on the mouse positions?

            • 3. Re: Drag and drop to apply color to art.
              poortip87 Level 1

              I came upon the NativeDragManager class of the CS Extension. We can use it to drag and drop objects from the panel to the application document. For this we use the ClipBoard and specify the format of the clipboard data. There are quite a few formats, namely, bitmap, text, url, file, etc. However, I couldn't use any of these so that I might drag a color from my panel to the document.

               

              Here is a code to drag and drop a text from panel to document,

               

              var clip:Clipboard = new Clipboard();

              clip.setData(ClipboardFormats.TEXT_FORMAT, designsDG.selectedItem.Colors);

              var allowedActions:NativeDragOptions = new NativeDragOptions();

              NativeDragManager.doDrag(designsDG.selectedItem as InteractiveObject, clip);

               

              Here designsDG is the datagrid containing the text.

               

              How can I do something similar for a color object?

               

              Any inputs?

              • 4. Re: Drag and drop to apply color to art.
                Harbs. Level 6

                Colors in Illustrator is custom data. The only way you could possibly use NativeDragManager would be if you could write custom data that matches what Illustrotor expects on a drop. I don't know whether Illustrotor will accept color data from an outside app at all. One test you could do to determine whether ther's something to even look at would be to see if you can drag a color from one version of Illustraotr to another. If the answer is no, then don't bother looking further...

                 

                HTH,

                Harbs