Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Menu Shortcuts
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Menu Shortcuts
Miscellaneous
Thread ID:
00454279
Message ID:
00454279
Views:
80
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	&& don't validate on cancel action (17 = ctrl+q)
  return .t.
endif
if <<Value is Invalid>>
  thisform.SaveDenied = . T.	&& prevent save
  return .f.
else
  thisform.SaveDenied = . F.	&& allow save
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
Next
Reply
Map
View

Click here to load this message in the networking platform