4D v14.3

Drop position

Home

 
4D v14.3
Drop position

Drop position 


 

Drop position {( columnNumber | pictPosY )} -> Function result 
Parameter Type   Description
columnNumber | pictPosY  Longint in List box column number (-1 if the drop occurs beyond the last column) or
Position of Y coordinate in picture
Function result  Longint in • 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
• Position of X coordinate in picture

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 or picture 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 the above 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 the destination object is a picture type variable or field, the command returns the horizontal location of the click and, in the optional pictPosY parameter, the vertical location of the click. The values returned are expressed in pixels and in relation to the local coordinate system.

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, a text or a picture, 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.

See the examples for the DRAG AND DROP PROPERTIES command.

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

 
PROPERTIES 

Product: 4D
Theme: Drag and Drop
Number: 608

 
HISTORY 

Modified: 4D v11 SQL
Modified: 4D v12

 
SEE ALSO 

Drag and Drop
DRAG AND DROP PROPERTIES

 
ARTICLE USAGE

4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)

Inherited from : Drop position ( 4D v11 SQL Release 6)