[Newbies] EventHandler "value parameters are passed as first of 3 arguments" ?

Marcel Taeumel marcel.taeumel at hpi.de
Thu Jan 11 10:03:22 UTC 2018


Hi, there. :)

Well, #on:send:to: works best if the target's source code is under your control. In your example, you would implement something like #setContentsEvent:from: in MyTextMorph. There, you have access to the mouse event and to the source morph to access the contents.

I would like to explain two other things, too:
1) You only need to call #addDependent: in the source if you want to implement or use #update: in the target. That's not the case in your example. You do not need it here.
2) The way #on:send:to:withValue: works is, in my opinion, broken. It only supports you to configure a single, hard-coded value, to be passed as first argument in a three-arg-selector. This is useless if you think about having multiple callbacks configured via #on:send:to:withValue:. We should fix that in the future.

Best,
Marcel
Am 11.01.2018 03:33:27 schrieb John-Reed Maffeo <jrmaffeo at gmail.com>:
_______________________________________________ Beginners mailing list Beginners at lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
#EventHandler halts with this warning from the method #on:send:to:withValue:

How does this work? I can't find an example.

I am trying to learn how to use TextMorph in an application. My simple test case is a morph containing two TextMorphs. I want the second morph to contain the contents of the first morph when that morph loses focus.

start -------------------
|borMor tMor1 tMor2 |

borMor := BorderedMorph new.
borMor color: Color white.
borMor width: 44.
tMor1 := TextMorph new.
tMor1 contents: 'Hello World!'.
tMor2 := TextMorph new.
tMor2 contents: '?????'.
tMor1 addDependent: tMor2.

borMor  layoutPolicy: TableLayout new;
listDirection: #leftToRight;
wrapCentering: #topLeft;
hResizing: #spaceFill;
vResizing: #spaceFill;
layoutInset: 2;
rubberBandCells: true.

borMor addMorph: tMor1. 
tMor1 addDependent: tMor2.
borMor addMorph: tMor2.
tMor1 on: #mouseLeave send: #contents: to: tMore2 withValue: #(tMor1 contents nil).


borMor openInWorld.

end -----------------

This may not be the best way to approach the problem, but I would like to know how to use the method in any case.

Thanks,

jrm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20180111/f5f6beed/attachment.html>


More information about the Beginners mailing list