Extra practice
Change your application so that last names and first names are displayed in the source window and each name goes to its respective text area in the target window. One way to do this is to edit the printOn: method in the Customer part and the transfer: method in the CustomerView part. The edited printOn: method is as follows:
printOn: aStream
lastName notNil ifTrue: [aStream nextPutAll: lastName.
firstName notNil ifTrue: [aStream nextPutAll: ', ']
].
firstName notNil ifTrue: [aStream nextPutAll: firstName]
The edited transfer: method is as follows:
transfer: aCwTransferProcCallbackData dropData: aCwDropTransfer
| array givenname surname transfer |
aCwTransferProcCallbackData value notNil
ifTrue:
transfer := aCwTransferProcCallbackData value.
array := transfer subStrings: $,.
surname := array first.
givenname := array last trimBlanks.
(self subpartNamed: 'Customer variable')
value: (Customer new
firstName: givenname;
lastName: surname)
]
To learn more about platform drag and drop, refer to materials on "Platform-integrated drag and drop" in the Programmer Reference.
Last modified date: 07/23/2020