#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim HTMLEditor1 As HTMLEditor
Private Button1 As Button
Private SELECT_TEXTFunc As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
SELECT_TEXTFunc = $"(function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
if (window.getSelection) {
if (window.getSelection().empty) { // Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) { // Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) { //IE?
document.selection.empty();
}
return text;
})();"$
Dim HTML As String = $"<p><em>"Do Not judge Me by my successes, judge Me by how many times I fell down And got back up again."</em></p>    - Nelson Rolihlahla Mandela"$
HTMLEditor1.HtmlText = HTML
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
Sub Button1_Action
Dim HTMLWVJO As JavaObject = HTMLEditor1
Dim WV As JavaObject = HTMLWVJO.RunMethod("lookup",Array("WebView"))
If WV.IsInitialized Then
Dim WE As JavaObject = WV.RunMethod("getEngine",Null)
Dim Selection As Object = WE.RunMethod("executeScript",Array(SELECT_TEXTFunc))
If Selection Is String Then
Log(Selection)
End If
End If
End Sub