You have to create a routine that will allow you to select and set bold on the text as people are typing... not unlike the interface used here to format the posts.
member(x).selectedText.fontStyle = [#bold]
* where x is the member's name or number.
the selectedText property of the text member creates a direct reference to that chunk of text in the member... we can see that if we did this in the message window after selecting some text (assuming my text member is named "text"):
-- <Prop Ref 1 58816fc>
By the Use example above you can probably extrapolate that other text/font formatting properties that operate at the character level can be directly accessed this way and set to the current text selection, ie: .font, .fontSize, etc.
When you're done and going to save, just save the .html of the member to the db:
someVar = member(x).html
-- code here to save the string variable to the db - make sure to escape characters such as single/double quotes... whatever the escape characters are for the particular db engine.
Thanks for your reply. So if the text is saved as html, also the information about bold text formatting is saved?
Earlier I found this link http://director-online.com/buildArticle.php?id=463 which tells about formatting text with Lingo. If I create a text editor with that guide, and text is saved to the database as html, should it display correctly later in the read mode?
I'm quite familiar with that article. It's great except for one small point: the selection code has some issues when you really test it out... use my code instead to apply the formatting, for example:
DOUG Article My Code
pMem.char[pStartChar..pEndChar].fontStyle = styleList
pMem.selectedText.fontStyle = styleList
pMem.char[pStartChar..pEndChar].fontSize = value
pMem.selectedText.fontSize = value
pMem.char[pStartChar..pEndChar].color = value
pMem.selectedText.color = value
... and so on...
Okay thanks. I created a much simpler code to my project, because I didn't need all the features that example offered. It works fine, except one little problem. I have two embedded fonts, one font which is used for a plain text and the other one is used for a bold text. The "Bold style on/off" button switches between these two fonts. It works fine, but when the user comes to edit an earlier text which was saved to database, there seems to be some empty characters in the text field after the written text and when the user clicks somewhere in the text field outside the written text and begins to write, the font is switched to Times New Roman.
Is there a way that the system could check the font of the written character and if it isn't embedded plain or bold font, it would switch the font to the embedded plain font?
When your text is loaded from the DB you could check the font of the last character, or remove as many whitespace chars from the end as you need to.
There is a bug when grabbing the rtf of a text member - which is how I suspect you're saving existing text to your DB - where Director adds an extra RETURN after your text. You can either remove the last instance of "\par" from the rtf before saving it to the DB, or trim the trailing RETURN character when fetching it back from the DB.
The text is saved as html. When I look the text in database editor, I can see one empty space after the last </font> tag and two empty spaces between </body> and </html> tags and two empty spaces after </html> tag in the end of the raw text. Those areas don't have any font tags, and they're probably causing the font to change to the default Times New Roman (when the text is loaded to the text field from database, there is 5 empty spaces after the actual text with default font).
Is there a way to solve this, maybe by forcing the font to be always one of the embedded fonts or somehow removing all those spaces after the written text?
The text is saved as html.
Is there a way to solve this ... ?
I think you should try saving and loading member.rtf instead of member.html - remembering to strip the introduced trailing RETURN character before or after.
on formatBugChars text_member, valid_fonts
case ilk( text_member ) of
text_member = member( text_member )
if NOT ( ilk( text_member ) = #member ) then
if NOT ( text_member.type = #text ) then
if NOT ( ilk( valid_fonts ) = #list ) then
char_count = text_member.char.count
repeat with char_num = char_count down to 1
last_char = text_member.char[char_num].ref
if valid_fonts.getOne( last_char.font ) then
text_member.char[char_num + 1..char_count].font = last_char.font
Thanks all, I saved the text as rtf and that seems to work. How I can add a bullet list "ball" to a text field between characters, to a place where focus currently is?
-- 149 works on PC... not sure if it's the same on mac as anything higher than 128 is the extended ASCII table and will be different between fonts/OSes..
just checked it out here: http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ext-mac.htm
and it looks like it's 165.