Displaying htmltext outside of xtalk
Forum rules
Be kind.
Be kind.
-
- Posts: 106
- Joined: Thu Dec 22, 2022 9:40 am
- Location: North Lincolnshire
- Contact:
Displaying htmltext outside of xtalk
I'm thinking about the best way of adding documentation to a CustomControl.
I wonder if it is possible to take some htmltext that is stored within the CustomControl and have it displayed in the computers default web browser. So I'm asking how to create a html file without actually saving the file to the hard drive?
S
I wonder if it is possible to take some htmltext that is stored within the CustomControl and have it displayed in the computers default web browser. So I'm asking how to create a html file without actually saving the file to the hard drive?
S
Mostly using a Mac Studio M2 running MacOS Sonoma.
- tperry2x
- Posts: 3210
- Joined: Tue Dec 21, 2021 9:10 pm
- Location: Somewhere in deepest darkest Norfolk, England
- Contact:
Re: Displaying htmltext outside of xtalk
To read html data, the browser will either want to read from a file or from an online URL.
Can I ask why you didn't want to write the html file to disk?
Can I ask why you didn't want to write the html file to disk?
-
- Posts: 106
- Joined: Thu Dec 22, 2022 9:40 am
- Location: North Lincolnshire
- Contact:
Re: Displaying htmltext outside of xtalk
Because it does not seem very elegant which of course is me trying to gold plate the solution.Can I ask why you didn't want to write the html file to disk?
My thinking is to include a custom property in the group of a custom control to store the instructions as htmltext formatted text and have them displayed in a web browser. I guess the next best thing is to save the text to a file and use the launch command but that may cause SIP issues.
Mostly using a Mac Studio M2 running MacOS Sonoma.
-
- Posts: 442
- Joined: Sat Sep 11, 2021 4:37 pm
- Contact:
Re: Displaying htmltext outside of xtalk
Adding a substack with a field to display the text would be simple enough, and may add less to the file size because field text style info is stored as binary data rather than serialized with XML tag pairs
- OpenXTalkPaul
- Posts: 2633
- Joined: Sat Sep 11, 2021 4:19 pm
- Contact:
Re: Displaying htmltext outside of xtalk
Well you could use the mark-down format for the documentation system that's already in place for Extensions (that's for script extensions and for extension builder modules). It's mark-down based, has a system of key/values for common info ("Author:", "Parameters:", "OS:", etc.) already worked out, and it can be parsed from inline comments in scripts so you can document your scripts as you're writing them.Skids wrote: ↑Fri Aug 16, 2024 4:32 pmBecause it does not seem very elegant which of course is me trying to gold plate the solution.Can I ask why you didn't want to write the html file to disk?
My thinking is to include a custom property in the group of a custom control to store the instructions as htmltext formatted text and have them displayed in a web browser. I guess the next best thing is to save the text to a file and use the launch command but that may cause SIP issues.
Or if you want to do your own thing and keep that sort of with your custom control group or objects, you could store instructions as Text, styled RTFText, or styled as HTMLtext formatted text in a custom property, perhaps named "customControlInstructions" that is attached to the group/object itself, then place that into a field or whatever for display when the user asks to see it. Then your control could have a line of script like this:
Code: Select all
if the optionKey is down then Answer information && the customControlInstructions of me
-
- Posts: 106
- Joined: Thu Dec 22, 2022 9:40 am
- Location: North Lincolnshire
- Contact:
Re: Displaying htmltext outside of xtalk
Thats an interesting idea. Would it be possible to get the mark-down text show in the dictionary as an entry as it does for extension builder modules?Well you could use the mark-down format for the documentation system that's already in place for Extensions (that's for script extensions and for extension builder modules).
I had a brief attempt at this but only with plain text which did not look very good. I will take another look to see if the answer dialog is capable of displaying styled text.Or if you want to do your own thing and keep that sort of with your custom control group or objects, you could store instructions as Text, styled RTFText, or styled as HTMLtext formatted text in a custom property, perhaps named "customControlInstructions" that is attached to the group/object itself, then place that into a field or whatever for display when the user asks to see it. Then your control could have a line of script like this:
Code: Select all
Code: Select all
if the optionKey is down then Answer information && the customControlInstructions of me
At the moment the instructions may be viewed by Ctrl Clicking on the controls icon in my tools palette but it would be good if they travelled with the control in some way or appeared as an entry in the dictionary.
Mostly using a Mac Studio M2 running MacOS Sonoma.
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
You should see me now in front of my computer with a fan going like the clappers and 40 degrees Celsius outside: nothing round these partsBecause it does not seem very elegant
seems very elegant at the moment.

Always wondered what the word 'elegant' means in the context of computer code.
Why do I wonder if htmlText from 'somewhere' inside a stack cannot be held in the clipboard of an operating system and then copied into a browser?
So: problem #1:
Does the OXT clipboard only work inside the IDE, or does it extend beyond it?
- -
Well that didn't work.
Let's try something else.
- -
Only as good as far as it goes, as
Code: Select all
copy fld "f2"
THIS works:
Code: Select all
on mouseUp
put the htmlText of fld "ff" into fld "f2"
select the text of fld "f2"
copy
end mouseup
-
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
HOWEVER:
#1 I cannot then open that in a browser and see anything but raw HTML code.
#2 I cannot paste directly into a web browser.
Trying to understand this:
https://livecode.com/use-the-web-browser/
#1 I cannot then open that in a browser and see anything but raw HTML code.
#2 I cannot paste directly into a web browser.
Trying to understand this:
https://livecode.com/use-the-web-browser/
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
This question is ever so slightly off topic (or not):
HOW do you paste HTML code into a web browser window?
HOW do you paste HTML code into a web browser window?
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
I must be a bit stupid (OK, OK: don't answer that), but in:
I cannot understand *browser Instance id here*.
Hmm:
- -
The 'chewy bit' seems to be that one can open a file, but it is NOT clear if one can open some code from inwith one's stack.
Code: Select all
revBrowserSet *browser Instance id here*, "url", ("file://")
Hmm:
- -
The 'chewy bit' seems to be that one can open a file, but it is NOT clear if one can open some code from inwith one's stack.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
NOT a wholly origianl idea:
https://use-livecode.runrev.narkive.com ... browserset
AND, needless-to-say: http://quality.runrev.com/show_bug.cgi?id=13831 has mysteriously vanished.
https://use-livecode.runrev.narkive.com ... browserset
I thought put revBrowserSet gBrowserID,”htmlText”,theContentsOfgFile might work, but it doesn’t.
9 years ago.As for the CEF browser I seem to remember reading something about it's the
way of the future but it is a work in progress.
AND, needless-to-say: http://quality.runrev.com/show_bug.cgi?id=13831 has mysteriously vanished.

https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Displaying htmltext outside of xtalk
OK: changing
https://quality.runrev.com/show_bug.cgi?id=13831
to
https://quality.livecode.com/show_bug.cgi?id=13831
won't let me in as I don't have a current licence.
Of course (!) there is probably a way with someone with a current LC licence to export the whole bug database in a way that is is accessible to all.
Shouldn't a bug database that contains bug reports re open source software also be open?
https://quality.runrev.com/show_bug.cgi?id=13831
to
https://quality.livecode.com/show_bug.cgi?id=13831
won't let me in as I don't have a current licence.
Of course (!) there is probably a way with someone with a current LC licence to export the whole bug database in a way that is is accessible to all.
Shouldn't a bug database that contains bug reports re open source software also be open?
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4832
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
-
- Posts: 442
- Joined: Sat Sep 11, 2021 4:37 pm
- Contact:
Re: Displaying htmltext outside of xtalk
Where would it go?richmond62 wrote: ↑Sat Aug 17, 2024 8:23 am This question is ever so slightly off topic (or not):
HOW do you paste HTML code into a web browser window?
I can't recommend strongly enough the joys of discovery to be found with even a cheap managed hosting account to learn how the web works.
Start with a simple hand-coded HTML file displaying "Hello World". Then add a little JS with alert and prompt to get the feel of how answer and ask work in that world. Then make an editable field with a submit button, and a CGI on the server to store it.
The web is a marvelous resource and ecosystem.
It is for the 21st century what HC was for 1987: a scriptable rich-media engine preinstalled on every GUI device.
Add a $5/mo managed hosting account and the world is your oyster.
- tperry2x
- Posts: 3210
- Joined: Tue Dec 21, 2021 9:10 pm
- Location: Somewhere in deepest darkest Norfolk, England
- Contact:
Re: Displaying htmltext outside of xtalk
I know of a couple of ways to do this:
The first button just opens whatever your default browser is, and goes to a URL.
The second button writes and html file and opens it in your default browser. But I know Skids didn't want to generate a file. Most browsers won't navigate to a page from having HTML code pasted into them from the clipboard, as this is seen as code injection. Far better to load from a file if at all possible.
Skids did also mention "outside of xtalk" in the title, so to me - that's in your default browser, rather than inside a htmlfield inside of the IDE or in a revBrowser widget-container-instance thing.
You could also set your xTalk script to delete the file in the background once the page is loaded:
This would then delete the file after it's loaded by the browser - no file exists on disk after that, and works on all platforms.
(if you try and reload the page after my 10 second delay, the file will be gone and you'll get:)
The first button just opens whatever your default browser is, and goes to a URL.
The second button writes and html file and opens it in your default browser. But I know Skids didn't want to generate a file. Most browsers won't navigate to a page from having HTML code pasted into them from the clipboard, as this is seen as code injection. Far better to load from a file if at all possible.
Skids did also mention "outside of xtalk" in the title, so to me - that's in your default browser, rather than inside a htmlfield inside of the IDE or in a revBrowser widget-container-instance thing.
You could also set your xTalk script to delete the file in the background once the page is loaded:
Code: Select all
on mousedown
put the temporary folder into tTmpFolder
put tTmpFolder & slash & "hPassedURLdata.htm" into tWebFile
put "<h1>Here's some text</h1><p>This is some text, you could pass this to the browser from script</p>" into tDataToWrite
delete file tWebFile
open file tWebFile
write tDataToWrite to file tWebFile
close file tWebFile
-- go to a URL
revGoURL "file://" & tWebFile
set the tCleanupThis of me to tWebFile
send tCleanupData to me in 10 seconds -- give time for the browser to launch, and load a file.... on slow systems
end mousedown
on tCleanupData
put the tCleanupThis of me into tFilename
if there is a file tFilename then
delete file tFilename -- the file is now gone
end if
end tCleanupData
(if you try and reload the page after my 10 second delay, the file will be gone and you'll get:)
-
- Posts: 106
- Joined: Thu Dec 22, 2022 9:40 am
- Location: North Lincolnshire
- Contact:
Re: Displaying htmltext outside of xtalk
Yes thats exactly what I meantSkids did also mention "outside of xtalk" in the title, so to me - that's in your default browser, rather than inside a htmlfield inside of the IDE or in a revBrowser widget-container-instance thing.

This is what I concluded. I will give it a try once I get back from sailing. I'm thinking of a handler named showInstructions or similar that opens the html formatted text that is stored in a custom property in the default browser. Thanks for writing it for me!You could also set your xTalk script to delete the file in the background once the page is loaded:
Another idea is to have the instruction text added to the dictionary but I suspect that this involves another file written in the correct format that is read when OpenXtalk loads. Again I shall investigate later.
Simon
Mostly using a Mac Studio M2 running MacOS Sonoma.
-
- Posts: 442
- Joined: Sat Sep 11, 2021 4:37 pm
- Contact:
Re: Displaying htmltext outside of xtalk
If the text is instructional material explaining how to use a tool in the IDE, what benefit leaving the IDE to display it?
OXT is very good at delivering rich media presentations. Simple text displays well. It can even include embedded images.
OXT is very good at delivering rich media presentations. Simple text displays well. It can even include embedded images.
-
- Posts: 106
- Joined: Thu Dec 22, 2022 9:40 am
- Location: North Lincolnshire
- Contact:
Re: Displaying htmltext outside of xtalk
Good question and I am open to suggestions. As you may know I am working on a palette stack to hold a collection of custom controls (built from script). The palette is capable of displaying instructions as shown in this example: Working on the idea that a custom control should be self contained I am planning to include the instructions in a custom property and I was investigating how the text could be displayed. I'll probably just tell the end user to display the custom property in a field or possible have the control create a new stack on the fly and display the text there.If the text is instructional material explaining how to use a tool in the IDE, what benefit leaving the IDE to display it?
Thoughts?
Simon
Mostly using a Mac Studio M2 running MacOS Sonoma.
-
- Posts: 442
- Joined: Sat Sep 11, 2021 4:37 pm
- Contact:
Re: Displaying htmltext outside of xtalk
Who is online
Users browsing this forum: No registered users and 1 guest