artificially causing a field to be left in a script
bobs at twft.com
Thu Sep 27 12:42:54 CDT 2012
You would need to put it in a mouseUp handler in any button a user can click on while editing. If someone tabs out of the field, and the field has been altered, closeField will get sent ok. The issue is clicking a button, and only with OS X (if memory serves me, which is to say check it yourself).
This brings up another point I have run into with editing data destined for a database. I don't really like to update data directly to a database as soon as I leave a field, because it is always possible in a multi-user system that someone got to the field and edited after another user reads it but before they update it. That means the first user will believe the column contains his edit, when actually it contains the edit of the second user who saved first. Sounds confusing but it can happen.
To avoid this, I usually include a way to enter an edit mode, as opposed to a browse mode. In edit mode I unlock the editable fields and save a copy of the data, which I populate the fields with. When the user exits edit mode I lock them again. This keeps the user from being able to edit the contents of a field when he is not in edit mode and getting the mistaken impression his edits will be saved. I then give the user the option to cancel or save. Upon saving I lock the table, then check the saved copy of the original data against the table data. If it is the same, I update the data, otherwise I alert the user and drop him back into edit mode with the updated data.
Obviously, if yours is not a multi-user system, most of that doesn't apply, but I do like to give the user clear feedback on what mode he is in. I know Filemaker writes to the database upon exiting the field, or going to another record. I never liked that.
On Sep 27, 2012, at 10:08 AM, Dr. Hawkins wrote:
> On Tue, Sep 25, 2012 at 9:59 PM, <dunbarx at aol.com> wrote:
>> on mouseLeave
>> focus on nothing
>> end mouseLeave
> focus on nothing seems to have possibilities here . . . but not from
> the mouse, as someone is likely to have reached the field by tab (in
> fact, probably)
> If I put the focus on nothing in a script, though, won't the script
> finish running before the focus?
> textChanged also seems to be a good solution--I can put a handler in
> the card. All I need to do is flip the "dirty" flag for the data, to
> make sure it gets saved.
> thanks to all
> Richard E. Hawkins, Esq.
> (702) 508-8462
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode