I've answered my own questions about the HTMLEditor control so this post now works as a reference to this very powerful control. Please add your contribution to it for properties I did not cover if you want. The HTMLEditor control handles .htm (.html) files to read and write from the control. Examples:
Save
Load
Focus (Erel's code)
I'd like someone to add how to actually clear the textbox by using this way, as it will be most useful as an option. Hopefully Erel want to add his answer to how to do this.
Save
B4X:
Dim HTMLEditor As HTMLEditor
File.WriteString("c:\myfolder\","TestHTML.htm",HTMLEditor.HtmlText)
Load
B4X:
Dim HTMLEditor As HTMLEditor
HTMLEditor.HtmlText = File.ReadString("c:\myfolder\","TestHTML.htm")
Focus (Erel's code)
B4X:
Dim HTMLEditor As HTMLEditor
Dim jo As JavaObject = HTMLEditor
Dim r As Reflector
r.Target = jo.RunMethodJO("getSkin", Null)
jo = r.GetField("webView")
jo.RunMethod("requestFocus", Null)
jo = jo.RunMethod("getEngine", Null)
jo.RunMethod("executeScript", Array("document.body.focus()"))
jo.RunMethod("executeScript", Array($"
var el = document.body;
if (typeof window.getSelection != "undefined"
&& typeof document.createRange != "undefined") {
var range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (typeof document.body.createTextRange != "undefined") {
var textRange = document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(false);
textRange.select();
}
"$))
I'd like someone to add how to actually clear the textbox by using this way, as it will be most useful as an option. Hopefully Erel want to add his answer to how to do this.
Last edited: