how to use RTFtext
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
how to use RTFtext
I have read a lot about RTF in this forum, but whatever script I copy, none works for me.
I want to change textfont and textstyle of field "url" with: "set textfont of field "url" to arial;set textstyle [bold] of field "url" to "italic, bold", but nope.
Is this also to do with RTFtext and if yes,HOW?
I want to change textfont and textstyle of field "url" with: "set textfont of field "url" to arial;set textstyle [bold] of field "url" to "italic, bold", but nope.
Is this also to do with RTFtext and if yes,HOW?
Re: how to use RTFtext
Hi Rob,
You have to take the dictionary literally, the examples:
Simon
You have to take the dictionary literally, the examples:
That is true or false not the bolded text to bold, italicset the textStyle["bold"] of field "name" to true
Don't leave out the quotes.set the textFont of button "Hello" to "Courier"
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: how to use RTFtext
Simon,
thanks for the lesson, but why did my "set textfont of field "url" to arial" do nothing?
My problem is that the dictionary confuses me.
So please tell me how to use RTFtext.
Thanks
Rob
thanks for the lesson, but why did my "set textfont of field "url" to arial" do nothing?
My problem is that the dictionary confuses me.
So please tell me how to use RTFtext.
Thanks
Rob
Re: how to use RTFtext
Hi Rob,
It does work here, maybe you can post a stack?
Simon
I'm not clear on this question?why did my "set textfont of field "url" to arial" do nothing?
It does work here, maybe you can post a stack?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: how to use RTFtext
Not necessary, it works now !!!It does work here, maybe you can post a stack?
But why works "set the textStyle ["bold"] of field "url" to true" well and " set the textstyle ["italic,underline"] of field "url" to true gives an errormessage: not a textstyle"italic,underline"
The dictionary shows this: "set the textStyle of field "url" to "italic,underline"
Please do not forget my question "how to use RTFtext"
Re: how to use RTFtext
errr..
Maybe start with a new stack?
Yeah, sorry about the rtf... will see if I have time tomorrow.
Simon
Again working here. Copied and pasted your text.The dictionary shows this: "set the textStyle of field "url" to "italic,underline"
Maybe start with a new stack?
Yeah, sorry about the rtf... will see if I have time tomorrow.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: how to use RTFtext
Hi Rob,
The first form is in the two upper examples, they include stylesList. That is the reason why works. "italic,underline" being the stylesList in your case.
The second form uses array syntax and is the bottom example. Here you can not use a stylesList but have to set the styles sequentially.
That is the reason why does NOT work.
Butworks.
I agree that the difference between the two forms seem subtle but are important. The second form has been introduced to give you a more granular control over styles, especially combining styles and overlapping styles down to character level. The upper form was not as flexible.
An example of the non-array form:
would leave you with word 3 just bold, not underlined nor italic.
In array form you can do this. this will make word 3 bold, underlined and italic.
I hope that make some sense.
Kind regards
Bernd
there are two variants of textStyle and the dictionary does a poor job of explaining this:set the textStyle of object to {empty | plain | stylesList}
set the textStyle of [chunk of] field to {empty | plain | stylesList}
set the textStyle[style] of object to {true | false}
The first form is in the two upper examples, they include stylesList. That is the reason why
Code: Select all
set the textStyle of field "url" to "italic,underline"
The second form uses array syntax and is the bottom example. Here you can not use a stylesList but have to set the styles sequentially.
That is the reason why
Code: Select all
set the textstyle ["italic,underline"] of field "url" to true
But
Code: Select all
set the textStyle["bold"] of field "url" to true
set the textStyle["italic"] of field "url" to true
I agree that the difference between the two forms seem subtle but are important. The second form has been introduced to give you a more granular control over styles, especially combining styles and overlapping styles down to character level. The upper form was not as flexible.
An example of the non-array form:
Code: Select all
set the textStyle of word 2 to 3 of field "url" to "italic,underline"
set the textStyle of word 3 of field "url" to "bold"
In array form you can do this.
Code: Select all
set the textStyle["underline"] of word 2 to 3 of field "url" to true
set the textStyle["italic"] of word 2 to 3 of field "url" to true
set the textStyle["bold"] of word 3 of field "url" to true
I hope that make some sense.
Kind regards
Bernd
Re: how to use RTFtext
Hi Simon & Bernd
Completely understood.
Thanks
Completely understood.
Thanks
Re: how to use RTFtext
Hi Rob,
RTF text is not helpful here.
Text in a field of Livecode has different levels of representation.
That means:
1. Text: if you say then you will get the unformatted text, no style information no nothing. The style/textFont of a default Livecode text is inherited from the stack. The stack defaults to a platform specific font and fontsize. is a variant of above form and does the same.
2. You have the HTMLtext of a field. will show you the style information Livecode uses to represent the text. You can also use the htmlText to copy all style information along with the text to another field. You would say, and watch for "set" since now you set a property of a field: This gives you exactly the text and the style of the text of field "url" in field "showText".
3. You have the styledText. You can say: Field "showText" will look exactly as field "url" as far as styles are concerned. Since styledText is a multi-level array you can currently only see what styledText contains in the debugger.
4. You have RTFText. You can say This shows you what RTF looks like. RTF is a format that contains all formatting information of a text, similar to htmlText but it is mainly used as a means to export text plus styling information to other word processors. That way you preserve your styling information and pass it to a different program that understands RTF text. I think all word processors do.
similarly to htmlText you can This gives you the text and styles of field "url" in field "showText"
5. You have unicodeText. The unicodeText of a field is a unicode representation of the text. It has no styling information, only text information. It is used in unicode text manipulation. You can say -> just text without styles.
6. you have formattedText. FormattedText of a field is a special case. It gives you the text of a field without styling but it adds a return at every line break. Suppose you have a text field that has a certain width and the text you write is more than what fits into that width the text will continue on the next line. FormattedText would return the text as is but with a return at the line break. Can be useful if you operate on text by script.
All that is going on behind the scene. RTF text is not what you want to operate on, although you could if you know the rules of the RTF format. My advice: don't even try.
All you were trying to do is change the style of a field and there are enough possibilities to do that without the need to actually work in one of above formats, you just set the textStyle or textFont or textHeight etc.
If you try above examples on two fields you will see what each does. It gives you a pretty good understanding of the way Livecode treats text field information. You also might want to look this stuff up in the User Guide and Dictionary.
Kind regards
Bernd
RTF text is not helpful here.
Text in a field of Livecode has different levels of representation.
That means:
1. Text: if you say
Code: Select all
put the text of field "url" into field "showText"
Code: Select all
put field "url" into field "showText"
2. You have the HTMLtext of a field.
Code: Select all
put the htmlText of field "url" into field "showText"
Code: Select all
set the htmlText of field "showText" to the htmlText of field "url"
3. You have the styledText. You can say:
Code: Select all
set the styledText of field "showText" to the styledText of field "url"
4. You have RTFText. You can say
Code: Select all
put the rtfText of field "url" into field "showText"
similarly to htmlText you can
Code: Select all
set the rtfText of field "showText" to the rtfText of field "url"
5. You have unicodeText. The unicodeText of a field is a unicode representation of the text. It has no styling information, only text information. It is used in unicode text manipulation. You can say
Code: Select all
set the unicodeText of field "showText" to the unicodeText of field "url"
6. you have formattedText. FormattedText of a field is a special case. It gives you the text of a field without styling but it adds a return at every line break. Suppose you have a text field that has a certain width and the text you write is more than what fits into that width the text will continue on the next line. FormattedText would return the text as is but with a return at the line break. Can be useful if you operate on text by script.
All that is going on behind the scene. RTF text is not what you want to operate on, although you could if you know the rules of the RTF format. My advice: don't even try.
All you were trying to do is change the style of a field and there are enough possibilities to do that without the need to actually work in one of above formats, you just set the textStyle or textFont or textHeight etc.
If you try above examples on two fields you will see what each does. It gives you a pretty good understanding of the way Livecode treats text field information. You also might want to look this stuff up in the User Guide and Dictionary.
Kind regards
Bernd
Re: how to use RTFtext
I'll stay away from RTFtext. Thanks for the examples; I tried them all
Rob
Rob