|
From: Dave C on 4 Apr 2008 20:14 I have a script that formats each line of a text member, setting various properties like the font, fontsize, color, etc. Basically it's a chat window that allows the user to format messages from others users in order to make it easier to read. Example, messages from Bob are in red, message from Bill are blue, italics, etc. As new messages arrive, they are appended to the end of the members text. Member("ChatWindow").text = Member("ChatWindow").text & RETURN & "Some new text" This wipes out the individual line formatting, returning everything to the default font, color, etc. I prefer to avoid having to go line by line, resetting the customized line properties each time a new message is received. So is there a way to add to the text without losing the customized line settings?
From: Chunick on 5 Apr 2008 11:45 use the undocumented .setContentsAfter() or .setContentsBefore() what I did for a chat program I wrote was get the line count before adding the line and then formatting the text how I wanted after adding the line - the reasoning was that I allowed a user to enter multiple lines using Shift+Enter key (like MSN messenger) and the user's username and maybe the post time would be appended to what they said, so it would not work getting the line count after the fact.. this gave me a bit more formatting control, which I wanted. lineCount = member("ChatWindow").line.count member("ChatWindow").setContentsAfter(RETURN & "Some new text") endLineCount = member("ChatWindow").line.count member("ChatWindow").line[lineCount + 1].fontStyle = [#italic] member("ChatWindow").line[lineCount.. endLineCount].color = color(255,0,0)
From: Dave C on 5 Apr 2008 14:29 Perfect. Many thanks. I think I will also include your Shift+Enter technique.
|
Pages: 1 Prev: Newperson question: how do I launch another app? Next: musical symbol Truetype |