Integrated Application Platform › Forums › General › Responding to change of value inside Record
- This topic has 7 replies, 2 voices, and was last updated 9 years, 7 months ago by
ajith.
-
AuthorPosts
-
October 14, 2013 at 10:23 am #766
ajith
ParticipantHi,
I have a controller defined as:Controller
{
Controls:
# (Record
(Vert
(tydate)(Button Update)
(Mshtml)
))
On_Update()
{.....After pressing Update, the Mshml is updated based on the value supplied by tydate. Is it possible to do this automatically without the help of Update button? In other words, as soon as user changes the value of tydate, the Mshtml should be updated.
Thanks in advance,
ajithOctober 15, 2013 at 4:10 pm #1022amckinlay
KeymasterTry adding a method Record_NewValue(field, value) – this is sent by RecordControl
Note: you have to tab off the field, or hit enter to trigger this.
You could also use Edit_Change() which is sent every time a field changes, but the date may not be valid if you’re in the middle of typing it.
October 16, 2013 at 7:32 am #1023ajith
ParticipantHi,
Thanks! I used the Record_NewValue() method and it is working fine.
ajithOctober 17, 2013 at 6:06 am #1024ajith
ParticipantHi,
I don’t understand how the Sending of messages is actually handled. I will list down what I understand :
1) The NewValue() method of RecordControl is to handle the messages Send by the contained fields, which in turn sends the Record_NewValue message.
2) The actual Sending (by either the field control or record control) is by calling the Send method defined in Control.I really do not understand how actually the Send method of Control works. I do not know how to put my doubt, though I will try. How actually does the control I code with a Record_NewValue() understand that indeed this particular message has been sent? Put another way, how does RecordControl passes on the message to the control I have coded? I understand how the code is written, but, what determines when this method (RecordNewValue) is executed by my control?
The Send method of Control sends messages for Field controls as well as RecordControl. For field controls, the source is an optional final argument (CookBook Determining the Source of Messages). However, for RecordControl, the source and value are in the opposite order and source isn’t named. This doesn’t cause problems because the method that will handle these messages are different? Am I right about this?
Thanks for your explanations in advance,
ajithOctober 24, 2013 at 10:02 pm #1025amckinlay
KeymasterIt is magic ๐
I will try to explain:
It starts when a control does .Send(name, …)
The name can be any string, but usually should be something specific e.g. Access_NewRecord so it isn’t confused with Send’s from other controls.
Send is a method that controls inherit from Control
Send does .Controller.Msg(name, …, source: origin)
i.e. it sends the original arguments plus the source (if the arguments don’t already contain a source).Controller is automatically set on controls when they are constructed. It is their “parent” Controller.
Only Controller’s (or child classes like PassThruController) can implement methods to “receive Send’s
Controller.Msg checks if the controller has a method with the name given as the first argument to Send.
If it finds a method it calls it
If it does not find a method it calls .Controller.Msg which will go to its parent Controller (the one containing this one)
If it reaches WindowBase without finding a method, then the Send is ignored and 0 (zero) is returned.
Since source is a named argument it is optional whether you receive it or not.
Send can send multiple arguments, as in the case of Record_NewValue which sends field and value. There will also be a source argument. “field” is the name of the field, whereas “source” is an instance of a control.
I hope that helps. There are some additional features like Redir and Recv but this is the normal flow.
Sorry for the slow response, I didn’t get the email notification again – this seems to be a recurring problem with this forum ๐
October 25, 2013 at 12:09 pm #1026ajith
ParticipantHi,
Thanks for the explanation. As usual, I will need more .
Send does .Controller.Msg(name, …, source: origin)
i.e. it sends the original arguments plus the source (if the arguments don’t already contain a source)Controller.Msg checks if the controller has a method with the name given as the first argument to Send.
What I want to know is how these two events give the result I want. I mean, they do not do anything explicitly. They only return values ๐
Please walk me through this example: I have MyController with a ButtonControl defined in it along with a On_Button method. When I click the button, the Send of Button does (Button’s).Controller.Msg() . Now what? The On_Button is defined in MyController, while .Controller.Msg() was called for Button. How is the link between Button and MyControl established and operated? I think, I can handle a little bit of technical jargon also if you need them to explain.
Thanks in advance,
ajithOctober 25, 2013 at 2:33 pm #1027amckinlay
KeymasterThe link is through .Controller which is set automatically during control construction.
That is what links the button to the controller.
Have a look at the code in stdlib (Control.Send, Controller.Msg)
October 25, 2013 at 4:36 pm #1028ajith
ParticipantHi,
I was looking at Control.Msg(). I haven’t digested everything in Controller.Msg(), but I think I am starting to understand something. Thanks for the explanation.
What computer does is magic! I am fascinated by it. It is even more wonderful to learn the secret of the magic.
ajith -
AuthorPosts
- You must be logged in to reply to this topic.