Forums > Javascript

Writing text into [comment] using Javascript

Mar 16 2010 | 11:52 pm

Hi.. So I’m starting out with javascript and I’ve managed to get to a certain point and have become stuck.

Part of my patch generates dynamically using javascript.. ive managed to get it working quite nicely, but there’s one thing I cannot figure out.

My patch’s javascript generates ‘n’ [umenu]s and places them in the patcher window. I have arranged for a [comment] to be generated directly above the [umenu] which I would like to show the number of the [umenu]…

i.e above the first generated [umenu] will be a [comment] of ‘1’. above the second, a [comment] of ‘2’ and so on.

I have got the [umenu]s populating using an array, and I was hoping to use the variable of my counter to populate the comment content too.. as below

theumenus[k] = this.patcher.newdefault(250+(k*100), 300, "umenu"); //make umenus
thecomments[k] = this.patcher.newdefault(250+(k*100), 280, "comment", k+1); //make comments, fill with ‘k+1’

I would have thought that after the "comment" field, the next field would be it’s content, but apparently not as all my generated [comment] boxes are empty.

However, this doesn’t put anything in the [comment] text field… how do I dynamically put text into a [comment]?? I’ve had a search around and have run into the ‘message (string, …)’ javascript, but I’m unclear how to use it (syntax wise). Supposedly it sends a message to the object it points at.

Any help muchly appreciated :)

Ooh, and, while I’m here… what is the javascript to make an object part of presentation mode?

Mar 17 2010 | 12:12 am

You use the variable you’ve set to refer to the object and call some of the avaiable methods. In this case you’ll want to do something like the example below.


thecomments[k] = this.patcher.newdefault(250+(k*100),280,"comment");
Mar 17 2010 | 12:28 am

Thankyou for the quick reply there :)

I get the syntax for the message script now, wasn’t sure before. Cheers!

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Javascript