Drag and drop within a list field
devin_asay at byu.edu
Fri Jul 16 11:48:16 EDT 2021
Some years back Scott Rossi created a nifty little demo called GetInLine that shows how to do the interface part of drag-reordering. It’s in his archive at http://tactilemedia.com/blog/2018/05/12/blasts-from-the-past/. It might give you a good foundation, even if you don’t use the exact interface he created.
I don’t think the data part of it should be too hard; just make sure you keep the visible list and the custom property synched the same. Or you could possibly use hidden text or metadata tags in you visible list to embed the type for each line.
Hope this helps.
> On Jul 16, 2021, at 9:06 AM, Paul Dupuis via use-livecode <use-livecode at lists.runrev.com> wrote:
> I have a scrolling list field that has contents like:
> the field has a custom property with the contents and a "type" for each name, so the data in the custom property look like:
> 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.
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
Office of Digital Humanities
Brigham Young University
More information about the use-livecode