PDA

View Full Version : Trapping ENTER key in Report Control



chuckatkinson
21-Oct-2009, 09:33 AM
I'm trying to trap the enter key in the report control. I've tried using one or both of the following, but it doesn't seem to work for ENTER (keycode 13)


Procedure OnComKeyDown Short ByRef llKeyCode Short llShift
Variant vRow
Showln ("Key is " + (String(llKeyCode)) )
If (llKeyCode=13) Begin
Get ComFocusedRow to vRow
End
End_Procedure

Procedure OnComPreviewKeyDown Short ByRef llKeyCode Short llShift Boolean ByRef llCancel
Variant vRow
Showln ("Key is " + (String(llKeyCode)) )
If (llKeyCode=13) Begin
Get ComFocusedRow to vRow
End
End_Procedure


The above will trap almost anything except "Tab" and "Enter". Note: Disregard the ComFocusedRow stuff in the above code.

I want to allow the user to press "Enter" on a row to view some additional information.

Any ideas?

Ian Smith
21-Oct-2009, 11:38 AM
Hi Chuck

Soooo near and yet so far….

The only one you didn’t try….

OnComKeyUp:)

Not sure why the others don't work. When I get a monment I'll investigate.

chuckatkinson
21-Oct-2009, 03:04 PM
Ok I got it to work, but had to devise a workaround to the fact that OnComKeyUp is sent when my ReportControl first gets activated.


Procedure OnComKeyUp Short ByRef llKeyCode Short llShift
Variant vRow
If ( (pbInKey(Self)) and (llKeyCode=13)) Begin
Showln ("Key is " + (String(llKeyCode)) )
Get ComFocusedRow to vRow
End
Set pbInKey to True
End_Procedure

Sonny Falk
21-Oct-2009, 03:34 PM
I'm trying to trap the enter key in the report control. I've tried using one or both of the following, but it doesn't seem to work for ENTER (keycode 13)


Procedure OnComKeyDown Short ByRef llKeyCode Short llShift
Variant vRow
Showln ("Key is " + (String(llKeyCode)) )
If (llKeyCode=13) Begin
Get ComFocusedRow to vRow
End
End_Procedure


The above will trap almost anything except "Tab" and "Enter". Note: Disregard the ComFocusedRow stuff in the above code.


You can try the old trustworthy On_Key command instead. On_Key works with ActiveX controls in the same way as with any other VDF control.

chuckatkinson
21-Oct-2009, 04:06 PM
Thanks Sonny. But that wouldn't have been as much fun :D

ActiveX handling is getting so much better these days.

I did change to use On_Key. Which solved the OnComKeyUp being in the keyboard buffer problem I was having...