DragDrop and the DragDestination

zryip theSlug zryip.theslug at gmail.com
Thu Jan 20 18:43:46 EST 2011


On Fri, Jan 21, 2011 at 12:05 AM, Bob Sneidar <bobs at twft.com> wrote:
> Well I've decided to forgo drag and drop and instead put to and from arrow buttons between the data grids. Drag and drop would have been cool, but I have stalled on getting things to work the way it seems they should, and when you mentioned scrolling during a drag and drop, I thought to myself, this is way to complicated a thing to try and do just to get a value from one list to another.

Hm, it depends of your need.

By scrolling the list during the drag & drop, I thought to something
near how the reorder capability of a datagrid behave, when you trying
to place a line outside the visible lines.

Now, if you want simply dropping a value in the visible lines of a
grid, you should not have to scroll the lines.

Basically, you need to know:

1. The number of the dropped line:
put the dgLine of the dgDataControl of the target into tTheLine

2. The name of the dropped column
put the dgColumn of the dgDataControl of the target into tTheColumn


And with this two informations you will be able to change a value of a
cell by the dragData value:

SetDataOfLine tTheLine, tTheColumn, line 2 of tTheDragData


Assuming that the first line of the dragData contains the datagrid
source name, your final dragDrop handler could be:

on dragDrop
   local tTheLine, tTheColumn, tTheDragData

   put the dgLine of the dgDataControl of the target into tTheLine
   put the dgColumn of the dgDataControl of the target into tTheColumn

   put the dragData["private"] into tTheDragData

   if (line 1 of tTheDragData is "Datagrid 1") then
      SetDataOfLine tTheLine, tTheColumn, line 2 of tTheDragData
      send "RefreshList" to me in 0 secs
   end if

end dragDrop

Maybe this handler is more appropriate to your needs?


Best regards,
-- 
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc




More information about the use-livecode mailing list