#Region SelectionChanged_Event --------------------------------------------------------------------------
' Line column in TextArea1
Dim jo As JavaObject = TextArea1
Dim event As Object = jo.CreateEventFromUI("javafx.beans.value.ChangeListener", "SelectionChanged", Null)
jo.RunMethodJO("selectionProperty", Null).RunMethod("addListener", Array(event))
#End Region ---------------------------------------------------------------------------------------------
. . .
End Sub
Sub SelectionChanged_Event (MethodName As String, Args() As Object) As Object
If MethodName = "changed" And TextArea1.Text <> "" Then
Dim IndexRange As JavaObject = Args(2)
Dim StartPosition As Int = IndexRange.RunMethod("getStart", Null)
' copy the text area to a list
Dim l As List
l.Initialize
l.AddAll(Regex.Split(CRLF, TextArea1.Text))
If l.Size > 0 Then
' echo the number of line excluding empty line at the end
' l.size = "lines in text area"
Dim the_start,the_end,line,column As Int
Dim the_str As String =""
the_start = 0
the_end = 0
For i = 0 To l.Size-1
' get line length
the_str = l.Get(i)
the_end = the_start+the_str.Length
If StartPosition >= the_start And StartPosition <= the_end Then
line = i+1
column= StartPosition - the_start
End If
the_start = the_end+1
Main.Coordonate4.Text ="Lines : "&l.size&" "
Main.Coordonate2.Text ="Ln : " &line
Main.Coordonate3.Text =" Col : "&column
Main.Coordonate1.Text ="Found : "
Next
Return Null
End If
End If
Main.Coordonate4.Text ="Lines : "
Main.Coordonate2.Text ="Ln : "
Main.Coordonate3.Text =" Col : "
Main.Coordonate1.Text ="Found : "
Return Null
End Sub