I want to have a listbox where I can scroll up and down using the cursor keys (no problem here it does that by default) now I wish to trigger a sub when I press enter or cMiddle.
It is possible with the Door library:
Obj is an Object and keyDownEvent is an Event (from the Door library).
B4X:
Sub Globals
'Declare the global variables here.
End Sub
Sub App_Start
Form1.Show
obj.New1(False)
obj.FromControl("Listbox1")
keyDownEvent.New1(obj.Value,"KeyPress")
End Sub
Sub keyDownEvent_NewEvent
obj.Value = keyDownEvent.Data
If Asc(obj.GetProperty("KeyChar")) = 13 Then
Msgbox("The following item was selected: " & _
ListBox1.Item(ListBox1.SelectedIndex))
End If
End Sub