Re: Can't trap the down arrow key
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Nov 25, 2003
- 386 views
----- Original Message ----- From: "Ron Austin" <ronaustin at alltel.net> To: <EUforum at topica.com> Subject: RE: Can't trap the down arrow key > > > Tommy Carlier wrote: > > > > > > Ron Austin wrote: > > > > > > > > > I want to use the up and down arrows to scroll back and forth through a > > > file, but I can't seem to get the up and down arrows to do anything. I > > > have a screen with six LText controls, Diag[1] thru Diag[6}. Here's the > > > > > > > > > code I used to see if my program recognized the down arrow key: > > > > > > onKeyDown[Diag[1]] = routine_id("onKeyDown_Win") > > > onKeyDown[Diag[2]] = routine_id("onKeyDown_Win") > > > onKeyDown[Diag[3]] = routine_id("onKeyDown_Win") > > > onKeyDown[Diag[4]] = routine_id("onKeyDown_Win") > > > onKeyDown[Diag[5]] = routine_id("onKeyDown_Win") > > > onKeyDown[Diag[6]] = routine_id("onKeyDown_Win") > > > > > > procedure OnKeyDown_Win(integer key, integer shift) > > > > > > setText(Diag[2],"Gotcha") > > > > > > if key = VK_DOWN then > > > setText(Diag[2],"Gotcha Again") > > > end if > > > end procedure > > > > > > Neither "Gotcha" or "Gotcha Again" show up on the screen. What do you > > > suppose the problem is? > > > > > > > Derek and Greg gave you the right solution, but I also noticed that you > > used routine_id("onKeyDown_Win") before you defined the procedure. > > Couldn't that also cause problems, or is it just in this example and not > > > > in your code? > > > > ______________ > > tommy online: http://users.pandora.be/tommycarlier > > > Sorry for the confusion. Let me start again. Here's my input section: > > constant > Lbl1 = create(LText,"Code",Win,20,50,60,20,0), > Lbl2 = create(LText,"Description",Win,20,80,60,20,0), > Lbl3 = create(LText,"Category 1",Win,20,110,60,20,0), > Lbl4 = create(LText,"Category 2",Win,20,140,60,20,0), > Lbl5 = create(LText,"Category 3",Win,20,170,60,20,0), > Lbl6 = create(LText,"Rank",Win,20,200,60,20,0) > > Diag[1] = create(EditText,{"",T_Code},Win,100,50,42,20,ES_UPPERCASE) > Diag[2] = create(EditText,{"",T_Desc},Win,100,80,278,20,ES_UPPERCASE) > Diag[3] = create(EditText,{"",T_Cat},Win,100,110,148,20,ES_UPPERCASE) > Diag[4] = create(EditText,{"",T_Cat},Win,100,140,148,20,ES_UPPERCASE) > Diag[5] = create(EditText,{"",T_Cat},Win,100,170,148,20,ES_UPPERCASE) > Diag[6] = create(EditText,{"",T_Rank},Win,100,200,20,20,ES_UPPERCASE) > setWindowBackColor(Win,rgb(155,255,255)) > > I said LText when I should have said EditText. What I want to do is get > a record and display it (I already can do this), and then when I hit the > up or down arrow it will get the next record or previous record and > display it on the screen. The Tsunami file system that I use can do > this. The main problem is that my procedure for detecting that the up > and down arrow keys was hit don't work. I did a search and found > someone who had the same problem and I pulled the code I used right off > this forum. I switched the code around to define the procedure before I > used the routine_id as Tommy suggested, but that didn't help. I sure > would like to get this working. > Okay! Now this is a lot different from your first description. Detail helps, no? I suspect that all you have to do is ... setHandler(Screen, w32HKeyDown, routine_id("my down key routine name")) And inside that handler code, you may have to check that whatever control actually has focus, does not 'need' the arrow down/up key for its own purposes - eg. a MleText or List field. Why will this work? Because the Screen control is used to trap events regardless of which control the event actually applies to. It is used to trap all events, not just those for a specific control. I suggest this because it sounds like you don't care which control has focus when the down arrow is pressed, so long as the next record is read in and displayed. -- Derek