Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Editbox with keypress event doesn't work properly
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01347649
Message ID:
01347657
Views:
10
Remove OTHERWISE clause with DODEFAULT() and seeif it helps.

>
>I'm having a problem with a custom class based on editbox. Basically, all properties are set to the VFP defaults. When the user presses Enter, I want the cursor to move to the next line in the box and allow the user to continue typing there. If the user positions the cursor in the middle of a line and presses Enter, I want the part of the line after the cursor to move down to the next line. The editbox works that way when there is no custom keypress method.
>
>However, I have added the following code in the keypress:
>
>
>LPARAMETERS nKeyCode, nShiftAltCtrl
>
>LOCAL nInsert, cNewText, nStart
>nInsert = THIS.SelStart
>IF This.SelLength = 0
>        nStart = MAX(nInsert,0)
>ELSE
>        nStart = MAX(nInsert,0)
>ENDIF
>DO CASE
>	CASE nKeyCode = -4   && F5
>		cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f5) + substr(THIS.Value, nStart+1)
>		This.Value = cNewText	
>		This.SelStart = nStart + Len(allt(userctrl.f5))
>		NODEFAULT
>	CASE nKeyCode = -5   && F6
>		cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f6) + substr(THIS.Value, nStart+1)
>		This.Value = cNewText	
>		This.SelStart = nStart + Len(allt(userctrl.f6))
>		NODEFAULT
>	CASE nKeyCode = -6   && F7
>		cNewText = LEFT(THIS.Value, nStart) + allt(userctrl.f7) + substr(THIS.Value, nStart+1)
>		This.Value = cNewText	
>		This.SelStart = nStart + Len(allt(userctrl.f7))
>		NODEFAULT
>	CASE nKeyCode = 48 .and. nShiftAltCtrl = 2			&& Cntl+0 pressed 
>		* do nothing at all
>		NODEFAULT 
>	OTHERWISE
>		DODEFAULT()
>ENDCASE
>
>
>and now the Enter key won't work properly. If I hit Enter, the cursor goes to the next line, but when I start typing again, the text comes out at the end of the previous line, instead of at the beginning of the new line.
>
>I'm not capturing the Enter key, and I didn't want to change it's behavior. What did I do wrong?
>
>TIA,
>Jen
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform