Drag and drop within a list field

Paul Dupuis paul at researchware.com
Fri Jul 16 11:06:48 EDT 2021


I have a scrolling list field that has contents like:

name1
name2
nameA
name3
name4
name5
nameB
name6
name7
nameC
name8
etc.

the field has a custom property with the contents and a "type" for each 
name, so the data in the custom property look like:

code<tab>name1
code<tab>name2
folder<tab>nameA
code<tab>name3
code<tab>name4
code<tab>name5
folder<tab>nameB
code<tab>name6
code<tab>name7
folder<tab>nameC
code<tab>name8
etc.

The type for each line can be either 'code' or 'folder'. I am trying to 
craft code for the field script that supports dragging a line that is a 
'code' or 'folder' onto a line that is a 'folder'. You can not drag a 
'code' or 'folder' onto a 'code' line.

I have a dragStart, dragMove and dragEnd handlers, but something is off 
with my code with regard to autoscrolling the field. (the actual list of 
names is much longer than my example above). When dragging near the 
bottom of the field, I try to detect if I am within a textHeight of the 
bottom of the field (or top if scrolling up) and and scroll the field, 
but it is very jerky. The user must keep moving the mouse around 
slightly so that continual dragMove messages are sent and I have other 
problems with highlighting the destination line when you are over a 
'folder' that you can drop on.

Does anyone have some "best practice" code for this capability that they 
would be willing to share? I admit coding drag and drop operations in LC 
is one of the areas I am least familiar with.




More information about the use-livecode mailing list