To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:

The Drag & Drop Framework in DataFlex

Lesson 2 - The basics - how it works

To facilitate Drag and Drop functionality in DataFlex, we’ve added a new component called the WebDragDropHelper. To begin adding Drag and Drop logic to your application, create an instance of the cWebDragDropHelper in your view.

From there, you can set up your drag and drop paths by adding DragActions and DropActions.

We’ll start with adding our Drag sources. Use Send RegisterDragSource passing along the control to enable dragging for as well as what Drag Action to support. The values for these drag actions are wrapped in constants, starting with C_WebDrag. Followed by the control name and finally the action.

Next, we’ll add our Drop targets. Use Send RegisterDropTarget passing along the control to enable dropping for, as well as what Drop Action to support. Similar to drag actions, the values for these drop actions are wrapped in constants, starting with C_WebDrop. Followed by the control name and finally the action.

By registering DragSources and DropTargets, we’re effectively connecting one set of controls to another; defining what pieces can be moved and where they can potentially be dropped. It’s important to know that you can register the same control as both a Drag Source and a Drop Target, allowing you to pick something up and drop it within the same control.

After we’re done registering our sources and targets, we can implement the OnDrop procedure in theWebDragDropHelper. Whenever a valid element is dropped, meaning from a registered drag source on a registered drop target for this helper, this event will fire. We can use this event to do something with the data that was interacted with, like update lists, add or remove items in the database, etcetera. The event will receive a handle to both the Drag Source and the Drop Target involved in this drag and drop execution as well as a WebDropPosition.

To get the Data involved in this action, you can query both the Source and the Target. Use Get DragData of hoDragSource to get the Drag Data from the source. Use Get DropData of hoDropTarget to get the Drop Data from the target. What this data is depends on the control it is being called on. A set of structs is provided which can be used for a specific control. In cases where you have multiple drag sources and or drop targets, you can use the IsObjectOfClass function to check what struct you should get the data to.

The WebDropPosition indicates whether the data was dropped on, before or after the target data within a control; or on an empty control entirely.

Note that all of this is just for a single instance of a WebDragDropHelper in your view. You can have multiple instances in a view, each with their own collection of sources and targets and their own implementation of the OnDrop event.

Alright, that was a lot to go through. In the next lesson we’ll look at an example setup and apply everything we just covered.