[squeak-dev] how to attachMorph: at the corner?

Bob Arning arning315 at comcast.net
Thu May 30 03:29:33 UTC 2013


compare the difference in these two:

Morph new openInWorld;
     color: Color red;
     position: 20 at 100;
     on: #mouseDown
     send: #value
     to: [(r _ RectangleMorph new extent: 500 at 500)
     openInHand;
     position: r center].

Morph new openInWorld;
     color: Color green;
     position: 20 at 200;
     on: #mouseUp
     send: #value
     to: [(r _ RectangleMorph new extent: 500 at 500)
     openInHand;
     position: r center].

If you want to keep the big rectangle in hand, the red button requires 
you hold the mouse button continuously. The green button retains the big 
rectangle until you click. HandMorph simply waits for the next mouse up 
or down to drop the morphs it's holding.

Cheers,
Bob



On 5/29/13 10:21 PM, Chris Muller wrote:
> Interesting.  I guess I thought that wouldn't work because it was
> "locked" to the hand based on its 'targetOffset' or something..
>
> Thanks a lot.  Although it seems to work there's one strange anomaly.
> For background, the action that causes #openInHand to be invoked is by
> the user left clicking on a button.  In your example, which is not
> invoked by a left click, the morph stays attached to the hand until I
> click it down.  With my openInHand: hack it seemed it would also stay
> attached without needing to hold down left button.  Very strange.
>
> Morphic is hard stuff.
>
> On Tue, May 28, 2013 at 5:56 PM, Bob Arning <arning315 at comcast.net> wrote:
>> (r _ RectangleMorph new extent: 500 at 500)
>>      openInHand;
>>      position: r center
>>
>> Cheers,
>> Bob
>>
>> On 5/28/13 6:05 PM, Chris Muller wrote:
>>
>> I'm using #openInHand, which opens my morph, centered under the hand.
>> I want to open it in the hand, but attached near the upper left corner
>> rather than the center.
>>
>> To do this, I factored the temp var "delta" calculation out of
>> HandMorph>>#attachMorph:, so it would take an argument instead,
>> attachMorph: aMorph at: delta.  Regular attachMorph now calls it
>> passing in the center point.
>>
>> Now I have an attach API that accepts an offset, guess I just need to
>> support openInHand: offset to call the new #attachMorph:at:.
>>
>> (Sigh) It works but is there a better way to do this?
>>
>>
>>
>>
>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130529/ecf81cdb/attachment.htm


More information about the Squeak-dev mailing list