How about...

        if (event.buttonDown) {
          var dragInitiator:DataGrid = DataGrid(event.currentTarget);
          var ds:DragSource = new DragSource();
          var row:Object = dragInitiator.selectedItem;
        
          if (row != null) {
            var draggedItem:Object = {label:row.label};
            var renderer:Canvas = new Canvas();
            var lbl:Label = new Label();
            renderer.addChild(lbl);
            lbl.text = row.label;
          
            ds.addData([draggedItem], 'items');
          
            // Convert the contentMouse locations to a negative number
            // and subtract 10 or so to offset the mouse pointer and the drag feedback image
            var offsetx:int = -dragInitiator.contentMouseX - 15;
            var offsety:int = -dragInitiator.contentMouseY - 15;           
            DragManager.doDrag(dragInitiator, ds, event, renderer,offsetx,offsety);
          }
       }   
           

Scotty Scott
http://www.franciswscott.com


On 7/20/06, Pan Troglodytes <[EMAIL PROTECTED]> wrote:

Ok, I'm trying to make my dragged grid item look a certain way and am running into two problems.  I'm dragging a grid row to a list.  But I don't want the default behavior of the giant grid row.  I want my own custom drag widget and I want it to pop up with its bottom right point at the current cursor position.  I have yet to be able to accomplish the latter.  Second, I want the dragging to start only when the mouse is actually clicked on the grid row.  With the code I have, it starts it if you select an item and then click and drag down in the blank area of the grid.

Here is some source code that basically shows what I'm doing.  It is not my actual source code, because that has a ton of other irrelevant crap.  But it does replicate the experience pretty closely.  I have commented out the part where I'm trying to figure out what to set the X/Y to.  If you have some wild guesses, I'd suggest trying them before posting. ;)  Believe me, I've thought of about a dozen things (like subtracting the renderers width off the X - won't work cause it isn't set) and all have been dead ends.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
  <mx:Script>
    <![CDATA[
      import mx.controls.DataGrid;
      import mx.controls.Label ;
      import mx.containers.Canvas;
      import mx.collections.ArrayCollection;
      import mx.core.DragSource;
      import mx.managers.DragManager;
     
      [Bindable] public var provider:ArrayCollection = new ArrayCollection([{label:"one"}, {label:"two"}, {label:"three four five"}]);

      private function startGridDrag(event:MouseEvent):void {
        if (event.buttonDown) {
          var dragInitiator:DataGrid = DataGrid(event.currentTarget);
          var ds:DragSource = new DragSource();
          var row:Object = dragInitiator.selectedItem;
         
          if (row != null) {
            var draggedItem:Object = {label:row.label};
            var renderer:Canvas = new Canvas;
            var lbl:Label = new Label;
            renderer.addChild(lbl);
            lbl.text = row.label;
           
            //renderer.x = ????
            //renderer.y = ????
           
            ds.addData([draggedItem], 'items');
            DragManager.doDrag(dragInitiator, ds, event, renderer);
          }
        }
      }
    ]]>
  </mx:Script>
 
  <mx:DataGrid id="grid" dataProvider="{provider}" width="200" height="200" mouseMove="startGridDrag(event)">
    <mx:columns>
      <mx:DataGridColumn headerText="label">
        <mx:itemRenderer>
          <mx:Component>
            <mx:Canvas>
              <mx:Label text="{ data.label}" color="blue"/>
            </mx:Canvas>
          </mx:Component>
        </mx:itemRenderer>
      </mx:DataGridColumn>
    </mx:columns>
  </mx:DataGrid>
  <mx:List dropEnabled="true" width="200" height="200"/>
</mx:Application>


--
Jason


__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to