Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Moving items using drag and drop – PB Docs 2019 – PowerBuilder Library

Moving items using drag and drop – PB Docs 2019

Moving items using drag and drop

At the window level, PowerBuilder provides functions and
properties for dragging controls onto other controls. Within the
TreeView, you can also let the user drag items onto other items. Users
might drag items to sort them, move them to another branch, or put child
items under a parent.

When you implement drag and drop as a way to move items, you
decide whether the dragged item becomes a sibling or child of the
target, whether the dragged item is moved or copied, and whether its
children get moved with it.

There are several properties and events that you need to
coordinate to implement drag and drop for items, as shown in the
following table.

Property or event

Setting or purpose

DragAuto property

TRUE or FALSE

If FALSE, you must call
the Drag function in the BeginDrag event.

DisableDragDrop property

FALSE

DragIcon property

An appropriate
icon

or

None!, which means the user
drags an image of the item

BeginDrag event

Script for saving the handle of the dragged item
and optionally preventing particular items from being
dragged

DragWithin event

Script for highlighting drop targets

DragDrop event

Script for implementing the result of the drag
operation

Example

The key to a successful drag-and-drop implementation is in the
details. This section illustrates one way of moving items. In the
example, the dragged item becomes a sibling of the drop target, inserted
after it. All children of the item are moved with it and the original
item is deleted.

A function called recursively moves the children, regardless of
the number of levels. To prevent an endless loop, an item cannot become
a child of itself. This means a drop target that is a child of the
dragged item is not allowed.

BeginDrag event

The script saves the handle of the dragged item in an instance
variable:

If you want to prevent some items from being dragged — such as
items at a particular level — that code goes here too:

DragWithin event

The script highlights the item under the cursor so the user can
see each potential drop target. If only some items are drop targets,
your script should check an item’s characteristics before highlighting
it. In this example, you could check whether an item is a parent of the
dragged item and highlight it only if it is not:

DragDrop event

This script does all the work. It checks whether the item can be
inserted at the selected location and inserts the dragged item in its
new position a sibling after the drop target. Then it calls a function
that moves the children of the dragged item too:

The DragDrop event script shown above calls the function
uf_movechildren. The function calls itself recursively so that all the
levels of children below the dragged item are moved:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x