This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20.6
Drop position
|
Drop position {( columnNumber | pictPosY )} -> Function result | ||||||||
Parameter | Type | Description | ||||||
columnNumber | pictPosY | Longint |
![]() |
List box column number (-1 if the drop occurs beyond the last column) or Position of Y coordinate in picture |
|||||
Function result | Longint |
![]() |
• Number (list box) or • Position (hierarchical list) or • Position in string (text/combo box/4D Write Pro area) of destination item or • -1 if drop occurred beyond the last 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 a list box, a hierarchical list, a text or picture field, or a 4D Write Pro area.
If you call Drop position when handling an event that is not a drag-and-drop event and that occurred over a list box, a combo box, a hierarchical list, a text, a picture, or a 4D Write Pro area, 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.
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 between two list boxes:
The right (source) list box object method contains the following code:
If(Form event code=On Begin Drag Over) //event must be selected for the list box
C_BLOB($tomove)
C_TEXT($val)
LISTBOX GET CELL POSITION(*;"LBPaid";$col;$row)
$val:=PaidCol{$row}
VARIABLE TO BLOB($val;$tomove)
APPEND DATA TO PASTEBOARD("mydrag";$tomove) //use a custom key
End if
The left (destination) list box object method contains the following code:
Case of
:(Form event code=On Drag Over) //event must be selected for the list box
C_BLOB($toGet)
C_LONGINT($rownum)
$rownum:=Drop position($colnum)
GET PASTEBOARD DATA("mydrag";$toGet) //get data
If(Pasteboard data size("mydrag")>0)&($colnum#1)) //If data are in the pasteboard
$0:=0 //we would accept the drop
Else
$0:=-1 //The drop is refused
End if
:(Form event code=On Drop) //event must be selected for the list box
C_BLOB($toGet)
C_LONGINT($rownum;$val)
$rownum:=Drop position($colnum)
GET PASTEBOARD DATA("mydrag";$toGet)
BLOB TO VARIABLE($toGet;$val) //get the value
If(Pasteboard data size("mydrag")>0))
If($colnum=1)
BEEP
Else
Case of //Adding of dropped values
:($colnum=2)
John{$rownum}:=John{$rownum}+$val
:($colnum=3)
Mark{$rownum}:=Mark{$rownum}+$val
:($colnum=4)
Peter{$rownum}:=Peter{$rownum}+$val
End case
DELETE FROM ARRAY(PaidCol;Find in array(PaidCol;$val)) //Update source listbox
End if
End if
End case
Product: 4D
Theme: Drag and Drop
Number:
608
Modified: 4D v11 SQL
Modified: 4D v12
4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)