|
From: Darrel Hoffman on 7 Apr 2008 00:47 Is there a way to make a block of text in a text field all align to the bottom? (Think chat-window) In other words, the most recently added text line will always be on the bottom, even if there aren't enough lines to fill the entire block. I can fake it by having the text start off with about 20-odd lines of RETURN's, but this makes the text field scrollable when it shouldn't be. Plus it just feels like a hack-job for what should have a more elegant solution somewhere, but I can't seem to find it...
From: Dave C on 7 Apr 2008 18:24 Since you need the text box to behave in a completely different way than it was designed to do, I wouldn't consider it to be a 'hack-job'. I would call it 'creative coding'. ;-) You could set the member's boxtype to #fixed (which won't show scrollbars) then switch it to #scroll when there are twenty one or more real lines of text. I have a similar 'chat' text member, I just never was concerned with the text starting at the top, or having the disabled scroll bars before the it was full. I do employ a fairly simple way of keeping the most recent text at the bottom once it fills up: member("SomeMemberName").scrollTop = member("SomeMemberName").height - sprite(someSpriteNum).height
From: Darrel Hoffman on 9 Apr 2008 10:44 > Since you need the text box to behave in a completely different way than > it was designed to do, I wouldn't consider it to be a 'hack-job'. I would > call it 'creative coding'. ;-) It's weird when you think about it - starting text at the bottom used to be the standard back in DOS days (Well, maybe Apple DOS - Just pulled up an MS DOS Prompt and it starts at the top, though maybe it was different before Windows? I forget.) And most chat programs I've seen preserve that arrangement. Since I want this to not just BE a chat window but very specifically LOOK like a chat window (fits the style of the project in general, kind of a retro/futuristic Enter The Matrix type world), I think I should work to make that behavior reflect properly in the game. > You could set the member's boxtype to #fixed (which won't show scrollbars) > then switch it to #scroll when there are twenty one or more real lines of > text. Could work, though counting lines can be tricky if somebody enters enough text to wrap onto a second (or third+) line. Director seems to count the number of RETURNs in a text field rather than the number of actual lines when you ask for a member(X).line.count. I'll probably end up replacing the default scrollbar with my own custom graphics for scrolling, so that might not be an issue ultimately. > I have a similar 'chat' text member, I just never was concerned with the > text starting at the top, or having the disabled scroll bars before the it > was full. I do employ a fairly simple way of keeping the most recent text > at the bottom once it fills up: > > member("SomeMemberName").scrollTop = member("SomeMemberName").height - > sprite(someSpriteNum).height I think if I have the scrolling controlled by my own custom graphics, something like that might do the trick.
From: Dave C on 9 Apr 2008 10:57 The great and powerful Wizard of Lingo, Chunick, has quite an elegant solution to counting the number of visual lines displayed (not RETURNS) which also scrolls automatically. I bet that with just minimal scripting, you could adapt it to pad the text with enough returns required to force the text to the bottom. http://www.chunick.com/director.htm
From: Dave C on 9 Apr 2008 11:49
Dave C wrote: > ...which also scrolls automatically... ok, My statement is not quite correct. Of course it scrolls down as you type (typical text box behavior). But if a script adds text to the member's text property it does not automatically scroll to the bottom. For that you need something like the code I suggested earlier. However Chunick's simple method of counting line (including wrapped lines) is still what you need. I think it would be easy to include some lingo which says "If this text member does not contain 20 visual lines, add just enough RETURNS to the beginning of the text to make 20 visual lines". |