Dropping
When a user releases the mouse button, a drop occurs on the target widget. Both the target and the source are notified. The target adapter first activates the dropCallback. The callData includes the source widget, the source model, the source items, the operation, and the mouse event. It also includes an offset for each source item relative to the mouse location. If, in response to the last dragOverCallback, the application set the emphasis to XmTARGETEMPHASIS, the callData for the dropCallback also contains the target item. If the emphasis was set to XmINSERTIONEMPHASIS, the callData contains the insertion index. Finally, the callData contains a doit flag, which an application can set to false if it is unable to perform the drop. In this case, the source adapter will activate its dragCancelCallback. Otherwise, it is the application's responsibility to perform the appropriate operation on the target widget and the underlying objects.
This portion of the example shows a sample dropCallback handler:
drop: targetAdapter clientData: clientData callData: calldata
"The items in the callData are being dropped onto the
receiver. These items must be from another source."
| toAdd |
toAdd := calldata sourceItems reject: [:anObject |
targetAdapter widget items includes: anObject].
targetAdapter widget addItems: toAdd position: calldata insertionIndex
After the target has triggered the dropCallback, the source adapter activates its dragCompleteCallback. The callData includes the source items, the target widget, the target model, the target item (if any), and the operation. It is the application's responsibility to perform the appropriate operation on the source widget and the underlying objects. For example, if the operation was XmMOVE, the application should remove the items from the source widget.
This portion of the example shows a sample dragCompleteCallback handler:
dragComplete: sourceAdapter clientData: clientData callData: calldata
"The items in the calldata have been dropped somewhere else."
calldata vote == XmMOVE ifTrue: [
sourceAdapter widget deleteItems: calldata sourceItems]
Last modified date: 03/29/2018