D-Pad Navigation Sample (?)

Dave Mitchell

Member
Licensed User
I have been trying to include D-Pad navigation in one of my projects and thanks to help from this group have made some progress. I thought I would post the finished example, but ran into a snag. I can use the D-Pad to cycle through several controls on a form, but am unable to use the center button (enter) to select the control. Ideally, when the center button was pressed, it would release control to the current control so further manipulation was possible. Is there a way to pass the center button so it isn't captured? Here is the sample.
 

Attachments

  • DPad HW Test.sbp
    2 KB · Views: 267

Erel

B4X founder
Staff member
Licensed User
Longtime User
You shouldn't use HardKey here.
First set the form's KeyPreview property to true (with the Door library).
This is an example of navigating between two textboxes:
oFrm is an Object.
B4X:
Sub Globals
    current = 1
End Sub

Sub App_Start
    Form1.Show
    ofrm.New1(false)
    ofrm.FromControl("Form1")
    ofrm.SetProperty("KeyPreview",true)
End Sub


Sub Form1_KeyPress (specialKey)
    If specialKey = cUpKey OR specialKey = cDownKey Then
        current = 1 + (current Mod 2)
        Control("TextBox" & current).Focus
    End If
End Sub
 
Top