I want to highlight texts in a rendered HTML with a background color or underline, given the start and end position of the portion of the text to highlight.
I wonder if this highlight function is already supported by current wxWidgets, when using wxWebView/wxHtmlWindow to render a HTML page.
Is it possible to highlight texts in a wxHtmlWindow or wxWebView?
Re: Is it possible to highlight texts in a wxHtmlWindow or wxWebView?
This is not supported by either control.
If the HTML code is under your control, you could just change it there. But i can't think of any way to do this for any random website. If you find some JavaScript code that does this, you can execute it with wxWebView::RunScript().
If the HTML code is under your control, you could just change it there. But i can't think of any way to do this for any random website. If you find some JavaScript code that does this, you can execute it with wxWebView::RunScript().
Use the source, Luke!
Re: Is it possible to highlight texts in a wxHtmlWindow or wxWebView?
Thanks! Yes, I do have full control of the HTML, and I can use JavaScript to highlight, but more than that I also want users to interact with the page. For example, clicking on the highlighted text can trigger a wxDialog showing up. Is that possible?doublemax wrote:This is not supported by either control.
If the HTML code is under your control, you could just change it there. But i can't think of any way to do this for any random website. If you find some JavaScript code that does this, you can execute it with wxWebView::RunScript().
Re: Is it possible to highlight texts in a wxHtmlWindow or wxWebView?
This is something that had to be done on the JavaScript side. Transferring the information back to the C++ code is the problem. There is no function for that. The common workaround is to change the title of the html page with JS and catch the wxEVT_WEBVIEW_TITLE_CHANGED event on the C++ side. That way you can transmit small pieces of information.
Use the source, Luke!
Re: Is it possible to highlight texts in a wxHtmlWindow or wxWebView?
thanks a lot, I think i'll try the workaround.doublemax wrote:This is something that had to be done on the JavaScript side. Transferring the information back to the C++ code is the problem. There is no function for that. The common workaround is to change the title of the html page with JS and catch the wxEVT_WEBVIEW_TITLE_CHANGED event on the C++ side. That way you can transmit small pieces of information.