Buttons are created dynamically, the single shared event. And key pressing are caught.
But how to invoke butVar_Click for each button according to the keycode via ClickButton(i)?
B4X:
Private Sub butVar_Click
Dim b As B4XView = Sender
...
Private Sub KeyPressed_Event(e As Event)
Dim KE As Reflector
KE.Target = e 'e is a KeyEvent instance
Dim KeyCode As String = KE.RunMethod("getCode")
'Log(KeyCode)
Dim EventType As String = KE.RunMethod("getEventType")
Select EventType
Case "KEY_PRESSED"
For i = 0 To 9
If KeyCode = $"DIGIT${i}"$ Or KeyCode = $"NUMPAD${i}"$ Then
ClickButton(i)
Exit
End If
Next
Case "KEY_RELEASED"
End Select
e.Consume
End Sub
...
But how to invoke butVar_Click for each button according to the keycode via ClickButton(i)?
Last edited: