Adding the target part
Add a new visual part named CustomerView to your application. In the Composition Editor, add a push button and the labels and text fields for firstName and lastName. Drop a Variable part on the free-form surface and change its type to Customer. Next, change the labels of the parts so the Composition Editor shows the following:
CustomerView target window
To enable dropping of customer names on the push button, change the settings for the dragDropSpec property of the push button as follows:
1. Set the data type to Platform Drag Drop Spec.
2. Set canBeDragTarget to true.
3. Specify only XmDROPCOPY for dropOperations.
4. Select OK and then close the Properties window.
Go to the Script Editor and add a private instance script named transfer:dropData: to CustomerView:
transfer: aCwTransferProcCallbackData dropData: aCwDropTransfer
aCwTransferProcCallbackData value notNil
ifTrue:
(self subpartNamed: 'Customer variable')
value: (Customer new
lastName: aCwTransferProcCallbackData value)]
To enable a dropped name to display in the Last name text field, make the following connections:
5. Connect the firstName attribute of the Variable part to the object attribute of the First name text field.
6. Connect the lastName attribute of the Variable part to the object attribute of the Last name text field.
7. Connect the dropTransferRequested event of the Drop site push button to the transfer:dropData: private script.
Last modified date: 06/11/2018