B4J Question [B4X] B4XTable - Keyboard navigation with Arrow Up and Down?

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
Is it possible to have keyboard navigation for row selection of B4XTable object, and Enter key for selection confirmation?
Thank you in advance!
 

Alexander Stolte

Expert
Licensed User
Longtime User
Try this:
B4X:
Dim r As Reflector
r.Target = B4XTable1.mBase
r.AddEventFilter("et", "javafx.scene.input.KeyEvent.KEY_PRESSED")
r.AddEventFilter("et", "javafx.scene.input.KeyEvent.KEY_RELEASED")
B4X:
Private Sub et_Filter (EventData As Event)

        Dim jo As JavaObject = EventData
        Dim code As String = jo.RunMethod("getCode", Null)
        Dim EventType As String = jo.RunMethod("getEventType", Null)

        If EventType = "KEY_RELEASED" Then

                If code = "RIGHT" Then
            B4XTable1.CurrentPage = B4XTable1.CurrentPage +1
                Else If code = "LEFT" Then
            B4XTable1.CurrentPage = B4XTable1.CurrentPage -1
                End If
            
        End If
End Sub
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Try this:
B4X:
Dim r As Reflector
r.Target = B4XTable1.mBase
r.AddEventFilter("et", "javafx.scene.input.KeyEvent.KEY_PRESSED")
r.AddEventFilter("et", "javafx.scene.input.KeyEvent.KEY_RELEASED")
B4X:
Private Sub et_Filter (EventData As Event)

        Dim jo As JavaObject = EventData
        Dim code As String = jo.RunMethod("getCode", Null)
        Dim EventType As String = jo.RunMethod("getEventType", Null)

        If EventType = "KEY_RELEASED" Then

                If code = "RIGHT" Then
            B4XTable1.CurrentPage = B4XTable1.CurrentPage +1
                Else If code = "LEFT" Then
            B4XTable1.CurrentPage = B4XTable1.CurrentPage -1
                End If
           
        End If
End Sub
Thank you very much Alexander!
This is for page change and it's definitely useful too!
I can't find something for row change with up and down arrow keys of the keyboard!
 
Upvote 0
Top