DragAndDropAreaMorph and PartsBinMorph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

DragAndDropAreaMorph and PartsBinMorph

Hannes Hirzel
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
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: DragAndDropAreaMorph and PartsBinMorph

Juan Vuletich-4
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
> [hidden email]
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org

1611-PartsBinMorph-JuanVuletich-2013Feb22-12h28m-jmv.1.cs.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DragAndDropAreaMorph and PartsBinMorph

Hannes Hirzel
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 <[hidden email]> 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
>> [hidden email]
>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>>
>

_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
Reply | Threaded
Open this post in threaded view
|

Re: DragAndDropAreaMorph and PartsBinMorph

Juan Vuletich-4
Hi Hannes,

Yes, it was my bug. Thanks for testing. The fix is in the update stream
at GitHub.

BTW, I also uploaded an updated image.

Cheers.
Juan Vuletich

On 2/23/2013 4:57 PM, H. Hirzel wrote:

> 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<[hidden email]>  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
>>> [hidden email]
>>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>>>
> _______________________________________________
> Cuis mailing list
> [hidden email]
> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>


_______________________________________________
Cuis mailing list
[hidden email]
http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org