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:
[color blue]
-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 "[color red]cNotify[/color]"
-Add Property "[color red]OkToLeave[/color]"
[/color]
In the [color red]GotFocus() Event[/color] of the TextBox:
[color blue]this.cnotify = SYS(2001,'NOTIFY')
SET NOTIFY OFF
This.oktoleave = .T.[/color]
In the [color red]KeyPress() Event:[/color]
[color blue]
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 [/color]
In the [color red]lostfocus() Event:[/color]
[color blue]
DO case
CASE this.cNotify = 'ON'
SET NOTIFY ON
CASE THIS.CNOTIFY = 'OFF'
SET NOTIFY OFF
ENDCASE[/color]
In the [color red]Valid() Event:[/color]
[color blue]
LOCAL lOkToleave
lOkToLeave = this.OkToLeave
this.OkToLeave = .t.
RETURN lOkToLeave[/color]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.