General information
Category:
Forms & Form designer
Title:
Substituting characters while typing in Edit box
I am designing a terminal emulator and need to map certain keys to special characters during user input.
The best solution I have come up with so far is rather cludgy, and am looking for a more elegant approach:
I am using the KeyPress Event of the edit box to trap for the key I need to convert and insert the character I want its place:
IF nKeyCode = 61 .AND. nShiftAltCtrl = 0
THIS.Value = THIS.Value + CHR(42)
nValueLength = LEN(THIS.Value)
lKeyChange = .T.
ENDIF
However, this by itself results in the Edit box value being the original value, plus CHR(42), plus the trapped key (in this case '[')
In order to get rid of the trapped key, I added this code to the InteractiveChange Event of the edit box:
IF lKeyChange
THIS.Value = LEFT(THIS.Value,nValueLength)
ENDIF
While this works, you will sometimes see the '[' character appear briefly in the edit box, then disappear, which obviously doesn't look very good.
Any ideas ?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only