[ENH] Drag/Drop: Morph>>aboutToDropInto:event:

Bob Arning arning at charm.net
Tue Jan 25 14:32:28 UTC 2000


On Mon, 24 Jan 2000 18:35:09 -0500 "David N. Smith \(IBM\)" <dnsmith at watson.ibm.com> wrote:
>Actually, HangMan does what you suggest in #1. It works except when the accepting morph does something to the morph immediately, like the trash can throwing the morph away, or a color changer morph which changes the color of a morph depending on the color of the place the morph is dropped, or a motion playing field morph which causes the dropped morph to move around? One never knows what an accepting morph might do before one has a chance to get the dropped morph back out; one has to be prepared to completely rebuild the dropped morph from scratch in order to make sure its state is the same.
>
>I've tried the trash can and color changing examples. There is no way to avoid the color change (without my enhancement), and the trash can throws the morph away (with preferences set right), producing a walkback when the morph is put back.

Hi Dave,

In the interest of exploring alternatives, here's one:

When the user tries to drag a letter, let them drag something else (a CarrierMorph) which holds a reference to the letter. When the carrier is dropped somewhere, the original letter is still unchanged and a determination can be made at that point to:

- leave the letter untouched
- install the letter where the carrier had been installed
- do something else entirely

Cheers,
Bob

============
'From Squeak2.7 of 5 January 2000 [latest update: #1789] on 25 January 2000 at 9:25:44 am'!
Morph subclass: #CarrierMorph
	instanceVariableNames: 'passenger '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-Experimental'!
Morph subclass: #SimpleLetterMorph
	instanceVariableNames: ' '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-Experimental'!

!CarrierMorph methodsFor: 'as yet unclassified' stamp: 'RAA 1/25/2000 09:25'!
justDroppedInto: aMorph event: anEvent

	(passenger wantsToBeIn: owner) ifFalse: [^self delete].
	owner replaceSubmorph: self by: passenger.
	passenger justDroppedInto: passenger owner event: anEvent.! !

!CarrierMorph methodsFor: 'as yet unclassified' stamp: 'RAA 1/25/2000 09:16'!
passenger: anotherMorph

	passenger _ anotherMorph! !


!SimpleLetterMorph methodsFor: 'as yet unclassified' stamp: 'RAA 1/25/2000 09:23'!
justDroppedInto: aMorph event: anEvent

	"do whatever needs to be done"! !

!SimpleLetterMorph methodsFor: 'as yet unclassified' stamp: 'RAA 1/25/2000 09:22'!
rootForGrabOf: aMorph

	^CarrierMorph new passenger: self! !

!SimpleLetterMorph methodsFor: 'as yet unclassified' stamp: 'RAA 1/25/2000 09:20'!
wantsToBeIn: anotherMorph

	"answer true or false depending..."
! !







More information about the Squeak-dev mailing list