<i><font color="#663300">Just trying out codebook and I'm wondering if anyone has ever implemented an explicit edit mode. By that I mean that all controls remain locked until a user presses an edit button at which point all controls unlock, the navigation functions disappear, and the user is presented with "save" and "cancel" options. </font></i> Yes, we've just done that. I'm not sure if it's the best "codebook" way to do it but here is a summary of what was done:
1. Create an "ieditbutton" class based on itoolbarbutton In the click event, toggle the locking/unlocking of the screen: _screen.ActiveForm.lAllowEdit=not _screen.ActiveForm.lallowedit 2. Modify or subclass itoolbar class to add ieditbutton to the toolbar. In the refresh of the toolbar, add code to make sure that the proper buttons are visible: WITH THIS IF _screen.activeform.lallowedit .cmdEdit.visible=.f. .cmdSave.visible=.t. .cmdCancel.visible=.t. ELSE .cmdEdit.visible=.t. .cmdSave.visible=.f. .cmdCancel.visible=.f. ENDIF ENDWITH
3. Add the property lAllowEdit to ibizobjform with the assign checked. Locking/Unlocking of the form takes place in lAllowedit_assign. The code in lAllowedit, includes: . a bunch of setall('Readonly',..) . refreshtoolbar to reset the buttons.
4.(the part I don't like)Modify save, cancel, next, previous ... Move the code from cbizobjform.save to ibizobjform.save to modify it: *-- If nothing has changed, don't do anything! IF !This.IsChanged() IF thisform.lallowedit *** Nothing changed but i still want to lock all the controls thisform.lallowedit=.f. endif RETURN lnRetVal ENDIF Later in save (before refreshform) CASE lnRetVal = FILE_OK ... IF thisform.lallowedit this.lallowedit=.f. endif This.RefreshForm()
Do the same thing to ibizobjform.cancel and prior, next, last, first (otherwise, the form will stay unlocked): IF thisform.lallowedit this.lallowedit=.f. endif This.refreshform()
Hope that helps. Good luck
©2002 Philippe Sevin |