Hi,
The textarea control has not selectionchanged event. I have tried to implement this event using jreflection. I set the property to selectionProperty and can get the indexrange in the changed event.
I am not familiar with reflection and javafx. Am I doing it right?
The code I use:
I also come across the RaisesSynchronousEvents error. The app does not crash. I add the code below to avoid the error log.
The textarea control has not selectionchanged event. I have tried to implement this event using jreflection. I set the property to selectionProperty and can get the indexrange in the changed event.
I am not familiar with reflection and javafx. Am I doing it right?
The code I use:
B4X:
Sub addSelectionChangedEvent(textarea1 As TextArea,eventName As String)
Dim Obj As Reflector
Obj.Target = textarea1
Obj.AddChangeListener(eventName, "selectionProperty")
End Sub
Sub sourceTextAreaSelection_changed(old As Object, new As Object)
Log(GetType(new))
Dim ta As TextArea
ta=sender
Dim indexString As String
indexString=new
Dim selectionStart,selectionEnd As Int
selectionStart=Regex.Split(",",indexString)(0)
selectionEnd=Regex.Split(",",indexString)(1)
If selectionEnd<>selectionStart Then
Main.sourceTermTextField.Text=ta.Text.SubString2(selectionStart,selectionEnd)
End If
End Sub
I also come across the RaisesSynchronousEvents error. The app does not crash. I add the code below to avoid the error log.
B4X:
#RaisesSynchronousEvents: SubThatCanRaiseEvent
Last edited: