version 2004.2 (Modified)
Drop position {(columnNumber)} Number
Parameter | Type | Description | |
columnNumber | Longint | List box column number or | |
-1 if the drop occurs beyond the last column | |||
Function result | Number | Destination element number (array or list box) or | |
item position (list), or -1 if drop occurred beyond the | |||
last array element or list item |
Description
The Drop position command can be used to find out the location, in a "complex" destination object, where an object has been (dragged and) dropped.
Typically, you will use Drop position when handling a drag and drop event that occurred over an array, a list box or a hierarchical list.
If the destination object is an array, the command returns an element number.
If the destination object is a list box, the command returns a row number. In this case, the command also returns the column number where the drop took place in the optional columnNumber parameter.
If the destination object is a hierarchical list, the command returns an item position.
In all cases, the command may return -1 if the source object has been dropped beyond the last element or the last item of the destination object.
If you call Drop position when handling an event that is not a drag-and-drop event and that occurred over an array or a hierarchical list, the command returns -1.
Important: A form object accepts dropped data if its Droppable property has been selected. Also, its object method must be activated for On Drag Over and/or On Drop, in order to process these events.
Examples
1. See the examples for the DRAG AND DROP PROPERTIES command.
2. In the following example, a list of amounts paid must be broken down per month and per person. This is carried out by drag and drop from a scrollable area:
The list box object method contains the following code:
Case of :(Form event=On Drag Over) DRAG AND DROP PROPERTIES($source;$arrayrow;$processnum) If ($source=Get pointer("SA1")) `If the drop does come from the scrollable area $0:=0 Else $0:=-1 `The drop is refused End if :(Form event=On Drop) DRAG AND DROP PROPERTIES($source;$arrayrow;$processnum) $rownum:=Drop position($colnum) If ($colnum=1) BEEP Else Case of `Adding of dropped values : ($colnum=2) John{$rownum}:=John{$rownum}+SA1{$arrayrow} : ($colnum=3) Mark{$rownum}:=Mark{$rownum}+SA1{$arrayrow} : ($colnum=4) Peter{$rownum}:=Peter{$rownum}+SA1{$arrayrow} End case DELETE ELEMENT(SA1;$arrayrow) `Updating of area End if End case
See Also
Drag and Drop, DRAG AND DROP PROPERTIES.