Re: Can't trap the down arrow key
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Nov 26, 2003
- 394 views
----- Original Message ----- From: "Ron Austin" <ronaustin at alltel.net> To: <EUforum at topica.com> Subject: RE: Can't trap the down arrow key [snip] > > > > 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 > <snip> > > vars = fld1&fl2&fld3 ...... > > setHandler(vars, w32HKeyDown, routine_id("keydown")) > > > some of my screens may have a dozen fields or so I changed it a bit so I > could use it in a loop and it works great! > sequence fields > > fields = repeat(6,0) > for i = 1 to 6 do > fields = fields & Diag[i] > end for > > setHandler(fields, w32HKeyDown, routine_id("keydown")) > I guess I didn't explain it enough. If you use the Screen control ID you won't have to do ... fields = repeat(6,0) for i = 1 to 6 do fields = fields & Diag[i] end for stuff at all. And your code ONLY works if one of the controls in Diag have focus. If another control has focus when you press the down arrow, nothing will happen. And besides, the code example you gave could be better written as ... fields = repeat(6,0) for i = 1 to 6 do fields[i] = Diag[i] end for which begs the question, why bother with the 'fields' varaible at all. Just do... setHandler(Diag, w32HKeyDown, routine_id("keydown")) But I still recommend setHandler(Screen, w32HKeyDown, routine_id("keydown")) because it doesn't matter which field on which window has focus then. Your "keydown" handler will always get invoked. -- Derek