Drop position

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 11 (Modified)


Drop position {(columnNumber)} Number

ParameterTypeDescription
columnNumberLongintList box column number or
-1 if the drop occurs beyond the last column
Function resultNumber Number (array/list box) or
Position (hierarchical list) or
Position in string (text/combo box)
of destination item 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, a hierarchical list or a text field.

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.

If the destination object is a text type variable or field, or a combo box, the command returns a character position within the string.

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 a list box, a combo box, a hierarchical list or a text, 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 FROM ARRAY(SA1;$arrayrow) `Updating of area
         End if 
   End case 

See Also

Drag and Drop, DRAG AND DROP PROPERTIES.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next