Textarea object?

Nov 23, 2011 at 12:49pm

Textarea object?

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?

#60189
Nov 24, 2011 at 3:53am

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.

regards,

O.

– Pasted Max Patch, click to expand. –
#216675
Dec 1, 2011 at 8:21pm

11olsen,

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].

– Pasted Max Patch, click to expand. –
Attachments:
  1. jsuitextarea.js
#216676
Dec 1, 2011 at 8:28pm

Do you know how I can control the line spacing? Can I set cellpadding or something like it on the cellblock?

#216677
Dec 2, 2011 at 10:01am

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..

cheers

btw: u used the name jsui_textarea in the patch

#216678
Dec 2, 2011 at 10:41am

I added a way to submit a message letter by letter. (growing text)

– Pasted Max Patch, click to expand. –

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.

O.

#216679
Dec 4, 2011 at 12:43am

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…)

– Pasted Max Patch, click to expand. –
#216680
Dec 6, 2011 at 11:57am

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

– Pasted Max Patch, click to expand. –

bye

#216681

You must be logged in to reply to this topic.