B4J Question [solved] How to check a user's press enter in TableView

giannimaione

Well-Known Member
Licensed User
Longtime User
Hi all,

in tableview there are event as:
focuschanged , mouseclicked , mousepressed and so on....
but action for check Enter press ????
how to do?
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can do it with the reflection library:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TableView1 As TableView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("1") 'Load the layout file, contains a tableview
    MainForm.Show

    Dim r As Reflector
    r.Target = TableView1
    r.AddEventHandler("TableView1_KeyPressed", "javafx.scene.input.KeyEvent.ANY")
End Sub

Private Sub TableView1_KeyPressed_Event(e As Event)
    Log("pressed " & e)
End Sub
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
thank you eurojam,
here my version
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TableView1 As TableView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.SetFormStyle("UNIFIED")
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
    Dim r As Reflector
  r.Target = TableView1
'  r.AddEventHandler ("TableView1_KeyPressed", "javafx.scene.input.KeyEvent.ANY")
  r.AddEventHandler ("TableView1_KeyPressed", "javafx.scene.input.KeyEvent.KEY_PRESSED")

   For i=1 To 100
     Dim o(3) As Object
     o(0)="Uno " & i
     o(1)="due"
     o(2)="Tre"
     TableView1.Items.Add(o)
   Next
End Sub

Private Sub TableView1_KeyPressed_Event(e As Event)
   Dim KE As Reflector
   KE.Target = e
   Dim KeyCode As String
   KeyCode = KE.RunMethod("getCode")
   Log(KeyCode)
End Sub
 
Upvote 0
Top