Storing styled text

Lets say that I edit the contents of the Text Area. I make some words bold and some words red colored.

Now I want to “save” this creation. Saving the pure text is easy. But if I want to save the “bold” and “red”, then I could do this manually by writing code.

I understand that I can manually count characters. Do things like

TextArea1.StyledText.Bold(5, 2) = True TextArea1.StyledText.TextColor(100, 4) = &cFF00FF etc.

So I could save the text and write custom code, as above, to stylize that text and, for example, display it in the future.

But this will be a little laborious. I want to make sure that there is no way to take the StyledText that I have created and “generate” the lines of stylizing that make it “stylized”

What I am trying to do is provide perhaps 15 different pages of help that are accessible in various parts of the program. I want to present that “help” in a styled Text Area. I am willing to write the code to transform the pages of help, but this is tedious and want to make sure that I am not missing something.

I come from a language that takes a “marked up” text file and displays it all stylized in the equivalent of a TextArea. That makes it very easy to “store” help files. You can create the “marked up” text file, by just editing the text in a Text Area and coping it to a text variable.

Doing the same thing in Xojo seems to be pretty difficult. I will have to store the text and manually write the code to transform it.

Am I correct?

I think the StyledText.RTFData is what you’re looking for :slight_smile:

Be aware that others have found issues with Styled Text and RTF with the fonts changing sizes.

What I would do is create an XML or JSON structure that stores the STYLERUN attributes… its a very simple format

Why not use HTML with HTMLViewer; for this help system

I played with the Rodriguez suggestion and I think that this will work for me and still be pretty “simple” – Although I could not figure it out without being pushed :slight_smile: . My “other” language produces a “simple” HTML using the basic styling tools that are available in the TextArea so I think that I can just write the help pages there and then store the created HTML in a data file or perhaps just as constants in my Xojo code itself. And display to the user in an HTMLViewer.

I created a constant: HELP_01. Assigned it the simple HTML text in the IDE.

Then in the code of a button:

Dim f As FolderItem = GetTemporaryFolderItem HTMLViewer1.LoadPage(Self.HELP_01, f)

And it seems to deliver what I want.

S idea is intriguing but for me would be more work. I might explore this out of curiosity.

Major thing was to learn that there was no drop-dead obvious way to go. Thanks all.

[quote=281983:@Dave S]Be aware that others have found issues with Styled Text and RTF with the fonts changing sizes.

What I would do is create an XML or JSON structure that stores the STYLERUN attributes… its a very simple format[/quote]

Only the Windows version of StyledText RTFData is broken, as well as font sizes. It works fine on Mac.

As for help, I have been using HTML for years.

I agree. I have moved all my on-screen help to HTMLViewer fields for my desktop applications. I build them in TextEdit then SaveAs in HTML. It is a single file as long as there are no graphics. It wraps well when resized, displays bullet points and headings very well, is cross platform and, if needed, it would be easily exported.

I have htmlviewer based help with styled text and images in one of my applications, xplatform.

I wrote the html using OS X TextEdit (by hand…). My main trouble was the alpha channel in some images (top of page intro rectangle with background color). At last, I bucklet the background color using GIMP instead of alpha channel and all was OK.