B4J Question How to detect keypress on Mac?

IndieDev

Active Member
Licensed User
Hi,

Am trying to detect keypresses on a Tableview on Mac OS X.

B4X:
'### Delete single selected item from tableview ###
Private Sub TableView1_KeyPressed_Event(e As Event)
    Dim KE As Reflector
    Dim KeyCode As String
   
    KE.Target = e
    KeyCode = KE.RunMethod("getCode")
'    Log(KeyCode)
    If KeyCode = "DELETE" Then
        TableView1.Items.RemoveAt(TableView1.SelectedRow)
        nTotItemCount = nTotItemCount -1
    End If
End Sub

The above code works fine on Windows, but doesn't work on a Mac.
How does one trap keypresses on Mac?

Can anyone help out here please.

Thanks.
 

IndieDev

Active Member
Licensed User
Never mind.
Should have thought this out before posting.

Used the following to get the keycode on Mac.

B4X:
'### Delete single selected item from tableview ###
Private Sub TableView1_KeyPressed_Event(e As Event)
    Dim KE As Reflector
    Dim KeyCode As String
   
    KE.Target = e
    KeyCode = KE.RunMethod("getCode")

    fx.Msgbox(MainForm, KeyCode, MainTitle)

    'If KeyCode = "DELETE" Then
    '    If nTotItemCount > 0 Then
    '        TableView1.Items.RemoveAt(TableView1.SelectedRow)
    '        nTotItemCount = nTotItemCount -1
    '    End If
    'End If
End Sub
 
Last edited:
Upvote 0
Top