Tipswip   >   Windows   >   Drag And Drop

Drag And Drop

You can drag and drop just about anything in Omnis Studio onto just about anything. If the $event method of the object supports "On evDrag" and "On evDrop" you can do it.

Under the Action properties tab, you must set the $dragmode to kDragData to allow dragging.
Under the Action properties tab, you must set the $multipleselect to kTrue to allow multiple line dragging.
Under the Action properties tab, you must set the $dropmode to kAcceptAll to allow dropping.

For some drag and drop operations you need to turn on $mousevents and use mouseover(). I always turn on $mousevents at the library level, negating the need to turn it on in the objects. If you are debugging a mouseover() be sure to calculate the mouseover value BEFORE any breakpoints. Calculate %L as Mouseover(kMLine) will be zero if you set you breakpoint before the Calculate %L.

You can take advantage of Studio's event message parameters to give you most of the information needed for drag and drop operations.

The various methods in the Drag and Drop demo are described in this section.

Run the demo to try out the various drag and drop operations.

Add Lines being Dropped

The sample code from behind the list:

Delete Lines being Dropped

The following is the sample code from behind the trash can button:

Drag and Drop Text

The following is the code behind the entry fields in the Drag and Drop Text demo.

Move Lines in the same list

You would use this if you have a list where you want to allow the user to change the order of the of the lines in the list. This method doesn't work well with smartlist data, because the moved lines are added and deleted, which would cause a bunch of unnecessary inserts and deletes on $dowork.

Remove Duplicates w/$removeduplicates

If you want to prevent duplicates from being added you will need to use $removeduplicates after adding the lines
or $search for matches before adding a line. $removeduplicates will resort the list order which may or may not be desireable.

Remove Duplicates w/$search

If you want to prevent duplicates from being added you will need to use $removeduplicates after adding the lines
or $search for matches before adding a line.$removeduplicates will resort the list order which may or maynot be desireable