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

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

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

jrm
#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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

marcel.taeumel
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
jrm
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

jrm
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

marcel.taeumel
Hi, there.

Sorry for my apparently confusing explanation. :-)

Please find a attached a change set to file-in via drag-drop into your image. It contains the class MyTextMorph. Then you can try out the following code in your workspace:

| container fieldOne fieldTwo |

container := Morph new.
fieldOne := MyTextMorph new.
fieldTwo := MyTextMorph new.

container
color: Color white;
extent: 400@100;
layoutPolicy: TableLayout new;
layoutInset: 2;
listDirection: #leftToRight.

fieldOne
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldTwo
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldOne contents: 'Hello World!'.
fieldTwo contents: '?????'.

container
addMorphBack: fieldOne;
addMorphBack: fieldTwo.

fieldOne addDependent: fieldTwo.

container openInWorld.

-----

Note that TextMorph has actually NO support for #on:send:to: at the moment bc. it overrides various methods that ignore EventHandler. You have to implement #handlesMouseOver:, #mouseLeave, and #update:with:. See the attached changeset.

Best,
Marcel

Am 12.01.2018 02:57:57 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

on-send-to-example.1.cs (820 bytes) Download Attachment
jrm
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

jrm
Marcel, Thanks!

Your example is very helpful. I think I can build on this :-)

It makes me think that  it would be reasonable to implement a variety of sub-classes of #textMorph for different data objects within my Business Model. By this I mean that I would have a DateTextMorp which would only allow valid dates or IntegerTextMorph which would only accept integer values or ProductNumberTextMorph which would only accept valid numbers from a dictionary of product numbers?

Cheers,

jrm

On Fri, Jan 12, 2018 at 6:05 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Sorry for my apparently confusing explanation. :-)

Please find a attached a change set to file-in via drag-drop into your image. It contains the class MyTextMorph. Then you can try out the following code in your workspace:

| container fieldOne fieldTwo |

container := Morph new.
fieldOne := MyTextMorph new.
fieldTwo := MyTextMorph new.

container
color: Color white;
extent: 400@100;
layoutPolicy: TableLayout new;
layoutInset: 2;
listDirection: #leftToRight.

fieldOne
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldTwo
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldOne contents: 'Hello World!'.
fieldTwo contents: '?????'.

container
addMorphBack: fieldOne;
addMorphBack: fieldTwo.

fieldOne addDependent: fieldTwo.

container openInWorld.

-----

Note that TextMorph has actually NO support for #on:send:to: at the moment bc. it overrides various methods that ignore EventHandler. You have to implement #handlesMouseOver:, #mouseLeave, and #update:with:. See the attached changeset.

Best,
Marcel

Am 12.01.2018 02:57:57 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

marcel.taeumel
Hi, there.

Try using the Tool Builder for that. Take a look at the change set attached to this mail.


Best,
Marcel

Am 15.01.2018 18:54:49 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel, Thanks!

Your example is very helpful. I think I can build on this :-)

It makes me think that  it would be reasonable to implement a variety of sub-classes of #textMorph for different data objects within my Business Model. By this I mean that I would have a DateTextMorp which would only allow valid dates or IntegerTextMorph which would only accept integer values or ProductNumberTextMorph which would only accept valid numbers from a dictionary of product numbers?

Cheers,

jrm

On Fri, Jan 12, 2018 at 6:05 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Sorry for my apparently confusing explanation. :-)

Please find a attached a change set to file-in via drag-drop into your image. It contains the class MyTextMorph. Then you can try out the following code in your workspace:

| container fieldOne fieldTwo |

container := Morph new.
fieldOne := MyTextMorph new.
fieldTwo := MyTextMorph new.

container
color: Color white;
extent: 400@100;
layoutPolicy: TableLayout new;
layoutInset: 2;
listDirection: #leftToRight.

fieldOne
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldTwo
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldOne contents: 'Hello World!'.
fieldTwo contents: '?????'.

container
addMorphBack: fieldOne;
addMorphBack: fieldTwo.

fieldOne addDependent: fieldTwo.

container openInWorld.

-----

Note that TextMorph has actually NO support for #on:send:to: at the moment bc. it overrides various methods that ignore EventHandler. You have to implement #handlesMouseOver:, #mouseLeave, and #update:with:. See the attached changeset.

Best,
Marcel

Am 12.01.2018 02:57:57 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

toolbuilder-example.1.cs (5K) Download Attachment
jrm
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

jrm
Marcel, I have been working with the change set you provided and I am not getting the same results you show in your mail (see attached).

If I make changes to name and date, those changes do not appear in the Note pane either.

The email field value is the only one which propagates to the note, because, I think, the method #checkMail: contains an invocation of #mail: which invokes #changed:. I don't see in the code where any of the other setters ( for username, message password, or date) are invoked.

The #accept method only displays the current values of the instance variables. I don't know where I should put the code which would invoke the setters. If the code you sent me is different than the code you used to create your screen shot, please send it along, that will probably help me understand.

Thanks again for your help,

jrm

On Tue, Jan 16, 2018 at 5:22 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Try using the Tool Builder for that. Take a look at the change set attached to this mail.


Best,
Marcel

Am 15.01.2018 18:54:49 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel, Thanks!

Your example is very helpful. I think I can build on this :-)

It makes me think that  it would be reasonable to implement a variety of sub-classes of #textMorph for different data objects within my Business Model. By this I mean that I would have a DateTextMorp which would only allow valid dates or IntegerTextMorph which would only accept integer values or ProductNumberTextMorph which would only accept valid numbers from a dictionary of product numbers?

Cheers,

jrm

On Fri, Jan 12, 2018 at 6:05 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Sorry for my apparently confusing explanation. :-)

Please find a attached a change set to file-in via drag-drop into your image. It contains the class MyTextMorph. Then you can try out the following code in your workspace:

| container fieldOne fieldTwo |

container := Morph new.
fieldOne := MyTextMorph new.
fieldTwo := MyTextMorph new.

container
color: Color white;
extent: 400@100;
layoutPolicy: TableLayout new;
layoutInset: 2;
listDirection: #leftToRight.

fieldOne
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldTwo
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldOne contents: 'Hello World!'.
fieldTwo contents: '?????'.

container
addMorphBack: fieldOne;
addMorphBack: fieldTwo.

fieldOne addDependent: fieldTwo.

container openInWorld.

-----

Note that TextMorph has actually NO support for #on:send:to: at the moment bc. it overrides various methods that ignore EventHandler. You have to implement #handlesMouseOver:, #mouseLeave, and #update:with:. See the attached changeset.

Best,
Marcel

Am 12.01.2018 02:57:57 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

MyBusinessApp.png (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: EventHandler "value parameters are passed as first of 3 arguments" ?

marcel.taeumel
Hi, there.

Those orange triangles indicate unsaved changes. That is, your widgets have state different to your model. In Squeak's text fields you can hit [CMD]+[S] or sometimes only [Enter] to accept the changes and write it back to the model.

In such ToolBuilder applications, you have two kinds of control flow:
1) Widget -> Model
Configured in your #buildWith: method, you tell the widgets about the model interface. The widget stores references to the model and the callbacks (e.g. #checkMail:). The widgets decide when to call the model. See your #buildWith: and look for #setText:, #getText:, #editText:.
2) Model -> Widget
Configured also in your #buildWith: method. However, models can be shared among multiple widgets. That's why you have to use #changed: to notify all widgets about modifications. Conveniently, the messages you tell the widget via #getText: matches your #changed: call. So, you just tell the environment: "Hey, anybody out there that uses #foobar to retrieve text contents? Do it again, you will get new stuff."

If you find some widget interactions annoying (such as [CMD]+[S]), look for widget configuration. In this case, take a look at PluggableTextSpec. You will find things like #askBeforeDiscardingEdits or #softLineWrap or #indicateUnacceptedChanges.

Anyway, PluggableTextSpec needs you to hit [CMD]+[S], PluggableInputFieldSpec just expects [Enter]. You can only bypass that via #editText:, which fires after (almost) any keyboard input.

Best,
Marcel

Am 25.01.2018 03:44:11 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel, I have been working with the change set you provided and I am not getting the same results you show in your mail (see attached).

If I make changes to name and date, those changes do not appear in the Note pane either.

The email field value is the only one which propagates to the note, because, I think, the method #checkMail: contains an invocation of #mail: which invokes #changed:. I don't see in the code where any of the other setters ( for username, message password, or date) are invoked.

The #accept method only displays the current values of the instance variables. I don't know where I should put the code which would invoke the setters. If the code you sent me is different than the code you used to create your screen shot, please send it along, that will probably help me understand.

Thanks again for your help,

jrm

On Tue, Jan 16, 2018 at 5:22 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Try using the Tool Builder for that. Take a look at the change set attached to this mail.


Best,
Marcel

Am 15.01.2018 18:54:49 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel, Thanks!

Your example is very helpful. I think I can build on this :-)

It makes me think that  it would be reasonable to implement a variety of sub-classes of #textMorph for different data objects within my Business Model. By this I mean that I would have a DateTextMorp which would only allow valid dates or IntegerTextMorph which would only accept integer values or ProductNumberTextMorph which would only accept valid numbers from a dictionary of product numbers?

Cheers,

jrm

On Fri, Jan 12, 2018 at 6:05 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

Sorry for my apparently confusing explanation. :-)

Please find a attached a change set to file-in via drag-drop into your image. It contains the class MyTextMorph. Then you can try out the following code in your workspace:

| container fieldOne fieldTwo |

container := Morph new.
fieldOne := MyTextMorph new.
fieldTwo := MyTextMorph new.

container
color: Color white;
extent: 400@100;
layoutPolicy: TableLayout new;
layoutInset: 2;
listDirection: #leftToRight.

fieldOne
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldTwo
hResizing: #spaceFill;
vResizing: #spaceFill.

fieldOne contents: 'Hello World!'.
fieldTwo contents: '?????'.

container
addMorphBack: fieldOne;
addMorphBack: fieldTwo.

fieldOne addDependent: fieldTwo.

container openInWorld.

-----

Note that TextMorph has actually NO support for #on:send:to: at the moment bc. it overrides various methods that ignore EventHandler. You have to implement #handlesMouseOver:, #mouseLeave, and #update:with:. See the attached changeset.

Best,
Marcel

Am 12.01.2018 02:57:57 schrieb John-Reed Maffeo <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners
Marcel,

Thanks for your reply.

I don't know why it is so difficult for me to grock (does anyone say that anymore?) this stuff, however your answer does not clarify my understanding:-( I will attempt to use #on:send:to::in my solution, however, I would appreciate a Workspace example of #on:send:to:withValue to satisfy my curiosity. I will write something in the wiki for future reference once I understand it :-)

Cheers,
jrm

On Thu, Jan 11, 2018 at 6:33 AM, Marcel Taeumel <[hidden email]> wrote:
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 <[hidden email]>:

_______________________________________________ Beginners mailing list [hidden email] 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



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners