Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor jumps to the different textboxes when backspace is pressed

Status
Not open for further replies.

Octagon6

Programmer
Mar 18, 2003
18
US
I know this question was asked already, but I can't find the thread anymore.

When the program is is running, and someones keeps hitting backspace, it jumps to the previous textbox. How did you guys fix that?
 
Set your form's Tabstop to .F.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Yeah, I could do that, but then my tabs won't work. Is there a way to do both?
 
Octagon6

You could disable the backspace, but I'm not sure that would desirable. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
nah... i don't think so, man. Thanks for your help anyways.
 
Octagon:

Paste in a program and run it; adapt to your needs:

PUBLIC oB1
oB1 = CREATEOBJECT("TestForm")
oB1.SHOW()

DEFINE CLASS testform AS FORM
DOCREATE = .T.

ADD OBJECT text5 AS TEXTBOX WITH ;
HEIGHT = 23, ;
LEFT = 192, ;
TOP = 132, ;
WIDTH = 100, ;
NAME = "Text5"
ADD OBJECT text1 AS TEXTBOX WITH ;
HEIGHT = 23, ;
LEFT = 192, ;
TOP = 36, ;
WIDTH = 100, ;
NAME = "Text1"
ADD OBJECT text2 AS TEXTBOX WITH ;
HEIGHT = 23, ;
LEFT = 192, ;
TOP = 84, ;
WIDTH = 100, ;
NAME = "Text2"

PROCEDURE noesc
LPARA obj

IF UPPER(obj.BASECLASS) # "TEXTBOX"
RETURN
ENDIF

IF EMPTY(obj.VALUE) AND LAST() = 127
KEYBOARD "{TAB}"
ENDIF
ENDPROC


PROCEDURE text5.LOSTFOCUS
THISFORM.noesc(THIS)
ENDPROC


PROCEDURE text1.LOSTFOCUS
THISFORM.noesc(THIS)
ENDPROC


PROCEDURE text2.LOSTFOCUS
THISFORM.noesc(THIS)
ENDPROC


ENDDEFINE

Good luck.

Al
 
In the valid event of the text box -- test for a backspace by using the LastKey()command
If LastKey() = 127
Return .f. && produce an invalid input notification
Endif

or--

If LastKey() = 127
Return 0 && return zero will keep the cursor in the box
Endif

Note however that with the second option if the backspace is the last keypress before someone tries to exit the form it will also appear as if the close box is not working. The same might be true if one tries to click into another object. I didn't test for that.

You might also be able to do something with the keypress event or the interactive change event. Get creative.


CDavis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top