Field Messages

Home Scripting Messages Field Messages

So far MoStacks implements two messages for fields: closeField and exitField.

MoStacks sends the closeField message to a field when it gets "closed" i.e. when it looses focus, and its value was changed since the field was "entered" i.e. got focus. (If the value was not changed, the exitField message is sent instead.)

A field gets closed if you select another field on the same card, if you issue a command that results in a change of the current card, or if you issue a command that switches to another view or opens a dialog. In other words: Whenever something changes that makes further input on the field impossible.

MoStacks sends the exitField message to a field when it is "exit" i.e. when it looses focus, and its value was not changed since the field was "entered" i.e. got focus. (If the value did change, the closeField message is sent instead.)

These two messages are useful mostly for two purposes: To implement scripts listening to the messages that check whether the value in the field is valid, and scripts that take some action based on the value.

Note that if a script deems the current value of the field to be invalid, there is no way yet for the script to force the user to correct it, mostly because there are no commands yet to influence the focus and force input back to the field that was closed.

Some possible "action" after a field is closed or exited would be to calculate something with the help of the field value and show the result in another field.

It's a good idea to keep closeField and exitField scripts rather small and simple. A long-running script could make navigating the stack sluggish. You could also get into trouble with such a script that runs into an error.

At the moment scripts are executed asynchronously. If you switch to another card, the closeField or exitField script of the field that was closed on the left card because of the switch runs more or less while the card is changed.

In theory, after a field loses focus, there should be only either a closeField or else an exitField message, but never both, and never more than once. Because of difficulties with the implementation, there can be however cases of a closeField message followed by an additional exitField message. It's also quite possible that there are circumstances that lead to more than one message of the same kind, although this was not yet observed so far.

These irregularities are again an argument for keeping the scripts small and simple.