Page 1 of 1
Detecting pressed keys
Posted: Tue Apr 13, 2010 3:29 pm
by jparada
Hi,
In a window with some controls (without any control gets the focus), I would like to detect when the user presses keys (A. .. Z and 0 ... 9), to detect those keys and then "show" a textbox control (previously hidden) and set the value property of the textbox with the contents of the user keys pressed.
I hope I've explained well.
Please any advice for this implementation.
Best Regards
Javier
Re: Detecting pressed keys
Posted: Tue Apr 13, 2010 6:19 pm
by mol
Helo Javier!
You can find fine example about iplementation of this idea in Calculator (placed some days ago by Vanguarda and changed by me).
Best regards, Marek
Re: Detecting pressed keys
Posted: Tue Apr 13, 2010 6:42 pm
by jparada
Hi Marek,
Please let me take a look.
Thanks.
Best Regards
Javier
Re: Detecting pressed keys
Posted: Tue Apr 13, 2010 9:02 pm
by mol
Please, download:
download/file.php?id=820
and analyze it.
You will find lines:
Code: Select all
@ 040,121 TEXTBOX ReadHide VALUE " " WIDTH 15 HEIGHT 25 NOTABSTOP ON CHANGE EvalKeys() ON ENTER Operator_Click("=") INVISIBLE
Calc.ReadHide.SetFocus()
*-------------------
Static Function EvalKeys()
Local c_Keys
if !Empty(Calc.ReadHide.Value)
c_Keys := Alltrim(Calc.ReadHide.Value)
do case
case c_Keys == "0" .or.;
c_Keys == "1" .or.;
c_Keys == "2" .or.;
c_Keys == "3" .or.;
c_Keys == "4" .or.;
c_Keys == "5" .or.;
c_Keys == "6" .or.;
c_Keys == "7" .or.;
c_Keys == "8" .or.;
c_Keys == "9"
Number_Click(Val(Alltrim(c_Keys)))
case c_Keys == "/"
Operator_Click("/")
case c_Keys == "*"
Operator_Click("X")
case c_Keys == "-"
Operator_Click("-")
case c_Keys == "+"
Operator_Click("+")
case c_Keys == "."
Decimal_Click()
case c_Keys == "C" .or. c_Keys == "c"
CancelEntry_Click()
case c_Keys == "R" .or. c_Keys == "r"
Cancel_Click()
case c_Keys == "W" .or. c_Keys == "w"
CancelMemo_Click()
case c_Keys == "S" .or. c_Keys == "s"
ReadMemo_Click()
case c_Keys == "M" .or. c_Keys == "m"
SMemo_Click()
case c_Keys == "A" .or. c_Keys == "a"
AddMemo_Click()
end case
Calc.ReadHide.Value := ""
endif
Return Nil
Re: Detecting pressed keys
Posted: Wed Apr 14, 2010 2:19 am
by srvet_claudio
Hola Javier,
en:
viewtopic.php?f=15&t=1331&start=0&bookm ... 160c6be6ea
postee algunas funciones que leen la entrada del teclado, espero que te sean de alguna utilidad.
Un saludo cordial,
Claudio Soto.