Version: 6.5.x and 6.7.x
The following method manages the drag-and-drop between scrollable areas located in the same process. When a user drags an item from one scrollable area to another, the item is deleted from the source area and inserted in the target area. To copy the item, press the CTRL key while performing the drag-and-drop.
To use it, you just need to place the following code in the scrollable area object method:
Case of
: (Form event=On Drop )
Drag_Drop (->ScrollableAreaVarName)
End case
The Drag_Drop method looks as follows:
`Drag_Drop method
C_POINTER($1;$Source)
DRAG AND DROP PROPERTIES($source;$SourceElem;$Process)
If ($SourceElem=-1)
`User is attempting to drag the entire Frame...
ALERT("Please refrain from dragging the entire frame...")
Else
$elem:=Drop position
If ($elem=-1)
`User is dropping item beyond the last item
$elem:=Size of array($1->)+1
End if
If (Is_CTRL_Pressed )
` if control is pressed we do not delete the source
` after the drag&drop
INSERT ELEMENT($1->;$elem)
$1->{$elem}:=$source->{$source->}
Else
INSERT ELEMENT($1->;$elem)
$1->{$elem}:=$source->{$source->}
DELETE ELEMENT($source->;$source->)
`deleting source element since it is a move
End if
End if
Also, the method Is_CTRL_Pressed is used to detect if the user presses the CTRL key:
C_BOOLEAN($0)
Case of
: (<>platform="Windows")
$0:=Windows Ctrl down
: (<>platform="Mac OS")
$0:=Macintosh control down
End case
Here, the <>platform variable is defined in the startup method using the following code
C_INTEGER($platform)
PLATFORM PROPERTIES($platform)
If (($platform=1) | ($platform=2))
<>Platform:="Mac OS"
Else
<>Platform:="Windows"
End if