[Cuis] DragAndDropAreaMorph and PartsBinMorph

H. Hirzel hannes.hirzel at gmail.com
Sat Feb 23 13:57:05 CST 2013


Hello Juan

Yes indeed this is impressive. Just two methods added in the change
set and one method changed. Copied in below.

The PartsBinMorph works but the position of the copied Morph is on the
top left corner instead at the mouse location.

This was tested with the change set 1611 you sent to the list, not
with the one you commited.

Regards
Hannes


PartsBinMorph>>
aboutToGrab: aMorph
	"submorph is being grabbed by a hand.
	Perform necessary adjustments (if any) and return the actual morph
	that should be added to the hand.
	Answer nil to reject the drag."

	^aMorph copy



Morph>>
aboutToGrab: submorph
	"submorph is being grabbed by a hand.
	Perform necessary adjustments (if any) and return the actual morph
	that should be added to the hand.
	Answer nil to reject the drag."

	^submorph "Grab it"


HandMorph>>
grabMorph: aMorph
	"Grab the given morph (i.e., add it to this hand and remove it from
its current owner) without changing its position. This is used to pick
up a morph under the hand's current position, versus attachMorph:
which is used to pick up a morph that may not be near this hand."
	| grabbed |
	self releaseMouseFocus. "Break focus"
	grabbed _ aMorph aboutToBeGrabbedBy: self.
	grabbed ifNil: [ ^self ].
	aMorph owner ifNotNil: [ :o | grabbed _ o aboutToGrab: aMorph ].
	grabbed ifNil: [ ^self ].
	^self grabMorph: grabbed from: grabbed owner

On 2/22/13, Juan Vuletich <juan at jvuletich.org> wrote:
> Hi Hannes,
>
> It was quite easy. Find it attached. (Will be iat GitHub tonight.)
>
> Cheers,
> Juan Vuletich
>
> On 2/20/2013 8:17 AM, H. Hirzel wrote:
>> Hello Juan
>>
>> You recently added a
>>      DragAndDropAreaMorph
>>
>> which serves very well as an example of a morph with only 7 methods
>> added which does a lot. It helps to see what is needed to override.
>>
>> A follow up question: How do I implement a PartsBinMorph?
>>
>> This means a container which has other morphs inside which I can drag
>> out and get copies of them.
>>
>> Kind regards
>> Hannes
>>
>> _______________________________________________
>> Cuis mailing list
>> Cuis at jvuletich.org
>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>>
>




More information about the Cuis mailing list