Not sure this is a simple problem, but one thing I like to do is create a 
global and then set it. I can then check for the mode when necessary. 

For simple edits I typically use a simple true false value in a global called 
isEditing. For more complex operations, I have a mode variable called gEditMode 
which can have at least 3 values: Newrecord, Edit or Browse, and sometimes a 
fourth called Validate. I do this because I want to provide visual clues about 
what the state of things are, such as an "X" button and a "Check" button, which 
I show and hide in a showEditMode handler. 

I also typically need to know if I am editing an existing record, or creating a 
new one, so that I can put default values into fields for new records, but NOT 
when editing! Otherwise I would constantly be overwriting edited values with 
default ones.

Once I have that, I will put a closeField, and menuPick handler in the stack 
script, card script or behavior script for the card, depending on the 
application. These will, among other things, set the value of the gEditMode 
variable to "Edit" or "Newrecord" depending on the user choice. 

Buttons are trickier, because I don't want to trap every mouseUp the user 
makes. I ended up creating a fieldDropper utility which reads the schema of a 
database, and then depending on a property of the current card, presents the 
developer (me) with a list of table columns for a specific table. I then ask a 
few questions about the type of control, and if a button or menu, I have a 
canned script that I set the script of the control to when I create it. 

Sometimes I require a user to click a button to enter the edit mode or 
newrecord mode. This avoids confusion and unwanted accidental data changes. It 
doesn't have to be a button, it could be a menu choice or a command key, but 
the user needs to just know intuitively what to do, or else have some visual 
letting him know that things have changed because he edited the information in 
some field. 

What I am discovering as I go along is that there are certain things I do 
repetitively, so that rather than hard coding the one thing I am trying to do, 
I instead approach things from a framework perspective, making things a great 
deal easier down the road. It certainly is not simple up front, but things 
begin to really hum along later. 

Bob




On Jan 3, 2012, at 1:51 PM, Sivakatirswami wrote:

> Without scripting every field, if you have a data entry system with multiple 
> fields, and you want to flag the user that he or she made a change but did 
> not save before click "next" or "Previous" to go to another record... what 
> would be the simplest method to check that the card was modified to then 
> prompt the user "Do you want to save your changes?"
> 
> Sivakatirswami
> 
> 
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to