[Gambas-user] Webview editing problem

Michael Hart ekimtrah at ...67...
Mon Dec 2 23:53:34 CET 2013


On 29/11/13 09:39, michael wrote:
> I have written a small project which is intended to test editing an html page (I would like to create a wysiwyg markdown editor). I have attached a copy. I am having trouble with editing the html programattically (http://gambasdoc.org/help/comp/gb.qt4.webkit/webview?v3, using the Eval method to run the JavaScript document.execCommand). I have copied the relevant code from the supplied WebBrowser project, and sending the Cut command works in the WebBrowser project but not in mine. Sending the Bold or Delete command does work in mine, using the keyboard to edit the html does work in mine (eg Ctrl C, typing etc.).
> I am using Debian 7 Gnome, with Gambas 3.4.1 which I installed from source (the repo version 3.1.1 is too old for another program I have written).
> Any Ideas ?
>
> Thank you
> Michael. 		 	   		
>
No reply yet, it has been a while ?? But I have found the solution, by 
going through the WebBrowser example and commenting out the lines I 
didn't need, one line or Sub at a time. What is needed was the line

   WebSettings[WebSettings.JavascriptCanAccessClipboard] = True

in the Form_Open() Sub.

This allows me to click on the cut button which executes the command


document.execCommand('Cut', false, false)


This makes sense, since the WebView help page says "using the Eval 
method to run the JavaScript document.execCommand)" however it isn't 
stated on the WebView help page that you need to enable this. I think 
that such a statement would be a good idea.

Michael



More information about the User mailing list