Textarea object?

    Nov 23 2011 | 12:49 pm
    Does anyone know of a Max object that's suitable for displaying a growing body of text? What I need is something with a scrollbar, that scrolls to the bottom as new text comes in, or can be told to do so.
    The [textedit] object has no scrollbar, cannot be scrolled programmatically, and automatically scrolls back to the top whenever the user stops interacting with it.
    Also 1) it inserts a space before appended text when you append, a well-intentioned behavior which AFAICT you can't turn off if you don't want it; and 2) if you send it a string with a comma or semicolon, the comma or semicolon appears backslashed in the textedit window: append "To be or not to be, that is the question;" => To be or not to be, that is the question;
    Curiously, the [text] object does not insert these backslashes. But the [text] object cannot be used for display. It shows its contents in a text window (with scrollbars) when you open it, but this window is not updated when new text is added, even if you send the [text] object another "open" message. You have to close the window and open it again.
    Any ideas how I can display a growing text?

    • Nov 24 2011 | 3:53 am
      i once made this solution with jit.cellblock. new text is appended and it autoscrolls down. it adds a new line with every message. so modification is needed if you want to append things letter on letter (it's more combining then). but this might get you started.
    • Dec 01 2011 | 8:21 pm
      This was very helpful! Thanks.
      I substituted a [jsui] object for your [p status] subpatcher. It handles the appending, word wrapping, scrolling. I needed the [jsui] because it gives you access to font metrics (via sketch.gettextinfo(text)) so you don't have to use a monospace font.
      There's more work to do here, for example it would be great if the [jsui] wrapper took its width and font properties from the corresponding properties of the jit.cellblock. But for now this is good for my purposes.
      Thanks again. Here it is in case you're interested, with the javascript file for the [jsui].
    • Dec 01 2011 | 8:28 pm
      Do you know how I can control the line spacing? Can I set cellpadding or something like it on the cellblock?
    • Dec 02 2011 | 10:01 am
      really cool! there's rowheight $1 to cellblock.
      i like that very much now with font metric. thank You
      I'm just scratching the surface with js, i don't know if you can adopt properties..
      btw: u used the name jsui_textarea in the patch
    • Dec 02 2011 | 10:41 am
      I added a way to submit a message letter by letter. (growing text)
      what definitely works is to set the text width limit with the cellblock size, but that doesn't rearrange text thats already in the cellblock.
    • Dec 04 2011 | 12:43 am
      Cool. I made some more changes so now you can set the font on the jsui object, which passes it on to the cellblock. Plus all the text gets rewrapped when you change the font or the width.
      (I know, the forum swallowed the _ in that filename for some reason.)
      I don't know why, but the type_in thing crashes my Max after sending 3 letters. (Max 6 running on Mac OS X 10.6.8...)
    • Dec 06 2011 | 11:57 am
      it crashed because there were strange characters in the message which are more than one int as ascii. made a raw fix. found out that i can send a carriage return to the cellblock. i will absolutely keep that for future usage. nice done skot edit: just noticed that a carriage return is also sendable in a message
    • Dec 16 2015 | 1:01 am
      These tutorials don't seem to work anymore in version 7. Does anyone have a solution for a "text area" type functionality?