In our "data entry" form class, we made the following design choices:
-Buttons’ captions are pictures.
-The user must press Add/Edit to add a new record or edit the current record.
-While adding / editing all actions are disabled except Save and Cancel.
-We wanted to be able to do data validation at the field / control level.
To provide keyboard and menu access to all buttons’ functions, we added a Record menu pad to our standard application menu, and used the “skip for” clause sync the menu with the buttons’ enabled/disabled status. Each bar has a procedure that attempt to set the focus on the right button and run its click() code.All seem to be OK, except for one thing: I'm not very happy with our sollution to prevent the save via menu shortcut, when the valid method of the control that has the focus returns .F..
My current solution is:
-Added SaveDenied property to the form class.
-The Valid method of the controls:
if lastkey()=17
return .t.
endif
if <<Value is Invalid>>
thisform.SaveDenied = . T.
return .f.
else
thisform.SaveDenied = . F.
endif
-Menu bar procedure for Save:
_screen.activeform.CmdSave1.setfocus()
if _screen.activeform.SaveDenied
<<Display Some Message>>
else
_screen.activeform.CmdSave1.click()
endif
What I don't like is the extra code in the Valid that must be added to each an every control that may return .F..
Is there a better way?
TIA
Doru