Control for text display, highlight and scroll
Re: Control for text display, highlight and scroll
Editing is possible in priciple, but i don't know if it's possible to handle large amounts of text.
https://www.w3schools.com/tags/tag_textarea.asp
Saving is more difficult as the browser has no access to the local filesystem. And i don't know any way to transport large amounts of data back from the webview into the C++ part of the application.
https://www.w3schools.com/tags/tag_textarea.asp
Saving is more difficult as the browser has no access to the local filesystem. And i don't know any way to transport large amounts of data back from the webview into the C++ part of the application.
Use the source, Luke!
Re: Control for text display, highlight and scroll
Hi,
Since all of it will be inside the "browser", it should be possible to save the page as HTML.
Unfortunately I am not sure how to do that...
Thank you.
Since all of it will be inside the "browser", it should be possible to save the page as HTML.
Unfortunately I am not sure how to do that...
Thank you.
Re: Control for text display, highlight and scroll
I built a small page with minimal CSS and JS. Unfortunately it works only properly when loaded from a "real" URL, not when loaded through a local file or SetPage(). Probably a security issue. So that seems to be a dead end.
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
function onToggleTextMarker(el) {
console.log(el)
el.classList.toggle('marked');
}
</script>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
.line {
color: #000;
}
.line:hover {
background-color: #eea;
cursor: pointer;
}
.line.marked {
background-color: #aee;
}
</style>
</head>
<body>
<span class="line" onclick="onToggleTextMarker(this)">some text here! </span>
<span class="line" onclick="onToggleTextMarker(this)">some more some text. </span>
<span class="line" onclick="onToggleTextMarker(this)">Lorem ipsum dolor sit amet consectetur adipisicing elit. </span>
<span class="line" onclick="onToggleTextMarker(this)">Doloremque maxime consequuntur repellendus voluptas odio commodi illo praesentium ea corporis! Doloribus?</span>
</body>
</html>
Use the source, Luke!
Re: Control for text display, highlight and scroll
I'll try to keep it simple. Basically I'll just need a report viewer only and highlighter thing to markdown the report. Then, of course, I want to save work i.e. the page as HTML.
Re: Control for text display, highlight and scroll
Well, that worked for me.
I tried to load it using:
Is that how you tried @doublemax?
I tried to load it using:
Code: Select all
wxString editorURL = "file:///C:/Users/purplex/Desktop/new146.html";
TextViewer = wxWebView::New(m_panel, wxID_ANY, editorURL);
Re: Control for text display, highlight and scroll
I tried that. The hover effect worked, but not the "toggle marked text with click". Try to load it with Chrome. There it worked for me even from a local file.
You might have to take a closer look at wxStyledTextCtrl. Unfortunately it's real pain to set up, it's badly documented and i've never used it, so i can't help with it
You might have to take a closer look at wxStyledTextCtrl. Unfortunately it's real pain to set up, it's badly documented and i've never used it, so i can't help with it
Use the source, Luke!
Re: Control for text display, highlight and scroll
That "toggle marked text with click" works for me perfectly. . How?
Re: Control for text display, highlight and scroll
You saved me from taking the complete Javascript script course over this small effect I was trying to achieve. Well done . All I need to do is export the highlighted text from the control as HTML file.
Re: Control for text display, highlight and scroll
The best you can possible do is to present a download button. You won't be able to write directly to the file system without user interaction.
I need to go to bed now, so no more experiments from me for today
If you want to take a shot at it, these are some things that might help:
https://www.w3schools.com/jsref/met_doc ... ssname.asp
https://stackoverflow.com/questions/366 ... ugh-server
I need to go to bed now, so no more experiments from me for today
If you want to take a shot at it, these are some things that might help:
https://www.w3schools.com/jsref/met_doc ... ssname.asp
https://stackoverflow.com/questions/366 ... ugh-server
Use the source, Luke!
Re: Control for text display, highlight and scroll
Thanks! If I just want to save the state of the html i.e. my highlights, can I use something called 'localStorage' https://javascript.info/localstorage ?
Re: Control for text display, highlight and scroll
I've never tried, but my feeling tells me that won't work when using a local html file.purplex88 wrote: ↑Thu Dec 12, 2019 2:19 pm Thanks! If I just want to save the state of the html i.e. my highlights, can I use something called 'localStorage' https://javascript.info/localstorage ?
Use the source, Luke!
Re: Control for text display, highlight and scroll
Maybe then I should simply use a real web browser for this