I’ve not looked into ace but would imagine it’s similar to Quill, that I use, courtesy of Tim Parnell.
You load the HTML you have quoted above into an HTMLViewer, using the LoadPage method. That gets the editor code and equally importantly, an environment within which it can work, into the HTMLViewer.
What goes into an ExecuteJavaScript method call is then some ephemeral javascript that, to be any use, will most likely make one of the API calls that the ace editor provides to do something specific. By ephemeral, I mean that the javascript is executed, and then thrown away. You can try this for yourself in any browser by putting:
javascript:alert("Hello");
into the address bar. So doing what you showed in your OP was a bit like Kirk saying something he thought was profound, and Spock replying “Fascinating, Captain.”. IOW, your HTMLViewer1 was being ironic.
For example, to load some text into the HTMLViewer ready for editing, I have to format it up as HTML first (so, change newlines into
etc). Then, what I do in my Xojo app, is something like this:
myHTMLViewer.ExecuteJavaScript("setHTML(""" + myTextAsHTML + """);")
where setHTML is a small piece of javascript added to my equivalent of the HTML page you put in your last post. In my case it looks like this:
function setHTML (htmlstr)
{
quill.clipboard.dangerouslyPasteHTML (htmlstr);
}
dangerouslyPasteHTML is the name of a quill API method; you’d have to look to see what functionality ace provides.
You mentioned not getting any error. When you use ExecuteJavaScript, the js you give it to execute will run and end whether it works or not - but it has no means of telling you anything. I was having this problem too until I added a window.onerror method to the HTML page:
window.onerror = function (errmess, url, linenum)
{
window.status = "HTMLEditEvent:Error:JavaScript error at line " + linenum + " - " + errmess;
}
Using window.status means I can use the Xojo StatusChanged event to obtain the new status string and then decode it.
What it all boils down to is that ace will provide a set of API calls you can make from your HTML page. You need to decide what set of API calls your Xojo app needs, and then have those calls make ace API calls, using ExecuteJavaScript and the StatusChanged event to go back and forth between them.