Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim tf As TextField
Dim keycode As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
tf.Initialize("tf1")
keycode.InitializeStatic("javafx.scene.input.KeyCode")
MainForm.RootPane.AddNode(tf,10,10,100,20)
setHandler(tf,"setOnKeyPressed","tf_KeyPress")
End Sub
Sub tf_KeyPress_Event(MethodName As String, Args() As Object)
Log(Args(0))
If asJO(Args(0)).RunMethod("getCode",Null) == keycode.GetField("UP") Then
' uppercase the text if 'up' is pressed
tf.text = tf.Text.ToUpperCase
asJO(tf).RunMethod("end",Null) ' make cursor stay at end of field
Log("up arrow pressed")
asJO(Args(0)).RunMethod("consume",Null)' eat the event to stop default behaviour
End If
End Sub
Sub asJO(o As JavaObject) As JavaObject
Return o
End Sub
Sub setHandler(ob As JavaObject,eventName As String,handlerName As String)
ob.RunMethod(eventName, Array(ob.CreateEventFromUI("javafx.event.EventHandler",handlerName,False)))
End Sub