Object

StyledText Class

Used to managed styled text independently of its display in an EditField. For an EditField, you can access the properties and methods of this class via the StyledText property of that class.

Methods
AppendStyleRun | ParagraphAlignment | StyleRunRange
Bold | ParagraphCount | Text
Font | RemoveStyleRun | TextColor
InsertStyleRun | Size | Underline
Italic | StyleRun |
Paragraph | StyleRunCount |

# Notes

The StyledText class enables you to apply style attributes to text independently of an EditField and its properties. Also, the StyledText class gives you the ability to align paragraphs (left, center, and right). The properties and methods of the StyledText class can be accessed from an EditField via its StyledText property, but you can also open, manage, and save styled text that is not displayed in any control.

The only operations that will update the contents of the EditField are the methods of the StyledText class. This means that obtaining a StyleRun (using StyleRun()) and setting the style attributes for that run will not be reflected in the EditField. If you want to operate on a StyleRun, you must remove the old run and replace it with the new run. Of course, the easier way to do it would be to make your changes using the StyledText methods instead of the StyleRun properties.

Because the EditField already has selection style attributes, the StyledText class honors that information. This means that you can set the style information using the selection methods that are available within the EditField class, and they will be reflected when getting StyleRun information (and vice versa). Not all of the style attributes for selections in the EditField class are available in the StyleRun class (such as Outline, Condense, Shadow, Extend and Plain). Of course, the first four are supported only on Mac OS "classic".

# Example

The following example uses the methods of the StyledText class to mark up and align text and display it in an EditField.

Dim Text as String // text to be displayed in EditField
Dim st,ln as Integer // start and length values of a paragraph
//define four paragraphs in Text
Text = "This is the text that we are going to save " _
+"into our file from the EditField."+ EndOfLine _
+"Isn't that interesting?"+ EndOfLine _
+"Man, I sure do love using RB to take care of my projects."+ EndOfLine _
+"That's because the RS Engineering staff is just so awesome!"
EditField1.StyledText.Text = text //four paragraphs in Text
EditField1.StyledText.Bold(5, 2) = True
EditField1.StyledText.TextColor(5, 2) = &cFF0000 //bold and red
EditField1.StyledText.Size( 7, 10) = 16
EditField1.StyledText.Underline(12, 4) = True //16 pt underline
EditField1.StyledText.Size(100, 4) = 18
EditField1.StyledText.TextColor(100, 4) = &cFF00FF //18 pt and Magenta
EditField1.StyledText.Font(0, Len(text) ) = "Comic Sans MS"
//center aliign second paragraph
EditField1.StyledText.ParagraphAlignment(1)= Paragraph.AlignCenter
//set this paragraph in Helveticta, 18 pt bold, red
//first get the start and length values for this paragraph...
st=EditField1.StyledText. Paragraph(1).StartPos
ln=EditField1.StyledText. Paragraph(1).Length+1
//next apply attributes...
EditField1.StyledText.Bold(st,ln)= True
EditField1.StyledText.Font(st,ln)="Helvetica"
EditField1.StyledText.Size(st,ln)=18
EditField1.StyledText.TextColor(st,ln)= &cFF0000

# See Also

EditField, StyleRun, Paragraph, Range classes.