on 4/25/07 7:32 PM, Pedro fp at [EMAIL PROTECTED] wrote:
> G'day Folks
>
> After a long hiatus I'm doing a bit of RB programming again.
>
> I'm currently working on something that requires trapping the tab &
> arrow keys in the KeyDown event of an EdifField.
> I thought I might get the tab key with ...
>
> If Key = Chr(9) Then
>
> But it doesn't work. I have no idea how to catch the arrow keys. Any
> clues?
>
> Cheers, Pedro :-)
I'm kind of partial to SelectCase for that. Also, I've subclassed 'ListBox'
(cl_lb_keys) for cases where I know I'm going to be using keys for whatever.
It uses NewEvents (like doKey_arrowLeft... along with a 'KeyDown' NewEvent)
to expose the key strokes in the instance. In the KeyDown event:
Dim top As Integer = Self.ListCount - 1
If top < 0 Then // The ListBox has no contents. Bail out.
Beep
Return True // Don't process the key any further.
End If
Dim row As Integer = Self.ListIndex
Select Case AscB(key)
Case 3 // ENTER key
Return doKey_ENTER(row)
Case 8 // Delete key
Return doKey_DELETE(row)
Case 9 // Horizontal TAB key (HT)
Return doKey_HT(row)
Case 13 // Carriage Return (CR)
If row = top Then
Beep
Else
// presumes that whatever is going to happen will take place in the
row that you're
// going to be arriving at... NOT the one that just detected the
KeyStroke.
row.Increment
Self.ListIndex = row
Return doKey_CR(row)
End if
Case 28 // LEFT Arrow (&h7B)
Return doKey_arrowLeft(row)
Case 29 // RIGHT Arrow (&h7C)
Return doKey_arrowRight(row)
Case 30 // UP Arrow (&h7D)
If row = 0 Then
Beep
Else
// presumes that whatever is going to happen will take place in the
row that you're
// going to be arriving at... NOT the one that just detected the
KeyStroke.
row.Decrement
doKey_arrowUP(row)
End If
Case 31 // DOWN Arrow (&h7E)
If row = top Then
Beep
Else
// presumes that whatever is going to happen will take place in the
row that you're
// going to be arriving at... NOT the one that just detected the
KeyStroke.
row.Increment
Return doKey_arrowDOWN(row)
End if
Case Else
// Handle the Key in the instance's KeyDown event, as per normal.
Return KeyDown(key)
End Select
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>