The problem: When we use the text box in VFP on a form, it is a little clumsy. What I mean is when you hit the backspace and you are at the beginning of the text box, the cursor leaves the text box and jumps to the previous box (according to your tab order), especially when the user hits the backspace and holds it to delete the entire content (It happens with me too).
Also, I hated it when I pressed the down/up key and the cursor jumps to different objects on the form.
So, this is what I DID:
-Create a new class based on TEXTBOX and name it what you wish (mine is TeknoBox) -Open the Class Designer and modify it. -Go to the class property -Add Property "cNotify" -Add Property "OkToLeave"
In the GotFocus() Event of the TextBox: this.cnotify = SYS(2001,'NOTIFY') SET NOTIFY OFF This.oktoleave = .T.
In the KeyPress() Event:
LPARAMETERS jKeyCode, jShiftAltCtrl IF jKeyCode = 127 OR jKeyCode = 4 OR jKeyCode = 19 OR; jKeyCode = 24 OR jKeyCode = 5 OR jKeyCode = 6 OR jKeyCode = 1 this.Oktoleave = .f. ELSE this.oktoleave = .t. ENDIF
In the lostfocus() Event:
DO case CASE this.cNotify = 'ON' SET NOTIFY ON CASE THIS.CNOTIFY = 'OFF' SET NOTIFY OFF ENDCASE
In the Valid() Event:
LOCAL lOkToleave lOkToLeave = this.OkToLeave this.OkToLeave = .t. RETURN lOkToLeave