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? |
(r _ RectangleMorph new extent: 500@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? |
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 <[hidden email]> wrote: > (r _ RectangleMorph new extent: 500@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? > > > > > > |
compare the difference in these two:
Morph new openInWorld; color: Color red; position: 20@100; on: #mouseDown send: #value to: [(r _ RectangleMorph new extent: 500@500) openInHand; position: r center]. Morph new openInWorld; color: Color green; position: 20@200; on: #mouseUp send: #value to: [(r _ RectangleMorph new extent: 500@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 [hidden email] wrote:(r _ RectangleMorph new extent: 500@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? |
Awesome. Thank you very much. It makes sense now that you've explained it..
On Wed, May 29, 2013 at 10:29 PM, Bob Arning <[hidden email]> wrote: > compare the difference in these two: > > Morph new openInWorld; > color: Color red; > position: 20@100; > on: #mouseDown > send: #value > to: [(r _ RectangleMorph new extent: 500@500) > openInHand; > position: r center]. > > Morph new openInWorld; > color: Color green; > position: 20@200; > on: #mouseUp > send: #value > to: [(r _ RectangleMorph new extent: 500@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 <[hidden email]> wrote: > > (r _ RectangleMorph new extent: 500@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? > > > > > > > > > > > |
Free forum by Nabble | Edit this page |