Help with repel in drag and drop
Stephane Ducasse
ducasse at iam.unibe.ch
Sun Feb 16 15:40:58 UTC 2003
Hi
After trying with diego yesterday, I made little progress in the
following behavior
I want for days: I want to have back in the hand a morph when it is
dropped into a morph that refuses it. Quite simple but still not
working.
I have two kind of morph: a receiver (red) and two DroppedMorph (blue
and green)
redMorph accepts blue morph but rejects a green morph (ReceiverMorph
example create them).
Now I do not reimplement handleDrop (which was a bad practice). Now I
have the nearly wished behavior working.
Here my question:
- only when I put a self halt before a call to
evt hand grabMorph: evt in the method rejectDropMorphEvent: evt below.
I'm sure that I'm missing an important invocation but cannot figure out
which one.
Thanks in advance for magic powder.
Stef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DragAndDropRepel.1.cs
Type: application/text
Size: 1699 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030216/b3c21d3c/DragAndDropRepel.1.bin
-------------- next part --------------
Morph subclass: #DroppedMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'xxxxxxxxxx'!
Morph subclass: #ReceiverMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'xxxxxxxxxx'!
!DroppedMorph methodsFor: 'initialization' stamp: 'sd 2/16/2003 15:52'!
initialize
super initialize.
color _ Color blue.
"self enableDrop: true"! !
!DroppedMorph methodsFor: 'dropping/grabbing' stamp: 'sd 2/16/2003
16:19'!
rejectDropMorphEvent: evt
"self halt."
"all the following methods works but only in the debugger."
"evt hand grabMorph: evt contents."
World activeHand grabMorph: evt contents.
"evt hand attachMorph: evt contents"! !
!DroppedMorph class methodsFor: 'blue' stamp: 'sd 2/16/2003 15:47'!
blue
^ self new! !
!DroppedMorph class methodsFor: 'blue' stamp: 'sd 2/16/2003 16:11'!
green
"self green openInWorld"
^ self new color: Color green; yourself! !
!ReceiverMorph methodsFor: 'initialization' stamp: 'sd 2/16/2003 15:52'!
initialize
super initialize.
color _ Color red.
bounds := 0 at 0 extent: 200 at 200.
"self enableDrag: true"! !
!ReceiverMorph methodsFor: 'dropping/grabbing' stamp: 'sd 2/16/2003
16:12'!
repelsMorph: aMorph event: ev
^ (self wantsDroppedMorph: aMorph event: ev) not! !
!ReceiverMorph methodsFor: 'dropping/grabbing' stamp: 'sd 2/16/2003
15:49'!
wantsDroppedMorph: aMorph event: anEvent
^ aMorph color = Color blue! !
!ReceiverMorph class methodsFor: 'as yet unclassified' stamp: 'sd
2/16/2003 15:48'!
example
ReceiverMorph new openInWorld.
DroppedMorph blue openInWorld.
DroppedMorph green openInWorld! !
Prof. Dr. St?phane DUCASSE (ducasse at iam.unibe.ch)
http://www.iam.unibe.ch/~ducasse/
"if you knew today was your last day on earth, what would you do
different? ... especially if, by doing something different, today
might not be your last day on earth" Calvin&Hobbes
More information about the Squeak-dev
mailing list
|