Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private TextField1 As TextField
Private SelMap As Map
Private TextArea1 As TextArea
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
DisableTextSelection(TextField1)
DisableTextSelection(TextArea1)
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Private Sub DisableTextSelection(tf As JavaObject)
If SelMap.IsInitialized = False Then SelMap.Initialize
Dim Prop As JavaObject = tf.RunMethod("selectionProperty",Null)
Dim O As Object = Prop.CreateEventFromUI("javafx.beans.InvalidationListener","SelectionChanged",Null)
Prop.RunMethod("addListener",Array(O))
SelMap.Put(Prop,tf)
End Sub
Private Sub SelectionChanged_Event (MethodName As String, Args() As Object) As Object
Dim JO As JavaObject = SelMap.Get(Args(0))
Dim IndexRange As JavaObject = JO.RunMethod("getSelection",Null)
If IndexRange.RunMethod("getStart",Null) <> IndexRange.RunMethod("getEnd",Null) Then
Dim Pos As Int = JO.RunMethod("getCaretPosition",Null)
JO.RunMethod("selectRange",Array(Pos,Pos))
End If
End Sub