0 Replies Latest reply on Feb 24, 2016 3:12 AM by dnyaneshlb

    Precisely drop item from extension to AI document

    dnyaneshlb Level 1



      I am using Illustrator version CC2015 (19.1) and mac Yosemite 10.10.3.

      I have created one extension having colors swatches. When user drag a color from extension to AI document, I am creating rectangle and filling it with dragged color. This gives effect of dragging a color from extension panel to document.

      So here is the deal, I can get this thing working but the location at which I am creating rectangle is not precisely where user has dropped color rectangle.

      Extendscript code goes here,


      var myDocument = app.activeDocument;  
              var artLayer = myDocument.layers.add();  
              var group = artLayer.groupItems.add();  
              var rect = group.pathItems.rectangle( 50, 50, 50, 50);  
              var x2=myDocument.activeView.bounds[0];  
              var y2=myDocument.activeView.bounds[1];  
              var zoom = myDocument.activeView.zoom;  
              var  y = ((dragDetails.mousePosition.mouseY/zoom)- 100/zoom); // mouseY  = event.screenY (event is drop event)  
              var  x = ((dragDetails.mousePosition.mouseX/zoom)- 95/zoom);  // mouseX  = event.screenX (event is drop event)  
              var newRGBColor = new RGBColor();  
              newRGBColor.red = dragDetails.RGBColor.Red;  
              newRGBColor.green = dragDetails.RGBColor.Green;  
              newRGBColor.blue = dragDetails.RGBColor.Blue;  
              rect.fillColor = newRGBColor;  


      Note line no 9 and 10.

      This works fine on windows. But on mac I am not getting exact X and Y co-ordinates.

      When I debugged further I came to know this strange thing -


      drag end co-ordinates = drag start co-ordinates


      i.e. event.screenX of drag start event = event.screenX of drag end event.

           event.screenY of drag start event = event.screenY of drag end event.


      Ideally I should get x and y co-ordinates diffrent for dragstart and dragend event. Seems a bug in cep.


      Please help. I am badly stuck.