Addressing TextButton Label Text via Javascript?

Nov 21, 2012 at 5:46pm

Addressing TextButton Label Text via Javascript?

I’m trying to change many textbuttons’ text with a simple javascript, but I can’t figure out how to address the button’s text. Is this possible or do I have to use a JSUI object to make the buttons first.

I’m attaching a small example.

  1. buttonText.js
Nov 21, 2012 at 6:19pm

Hi Whale Bone,

One way of doing it is to just send a message to the object, using ‘myobject.message()’:

inlets = 1;
outlets = 1;
autowatch = 1;

p = this.patcher;
var textvalues = ["Off","On"];

function ToggleButton(a) {
if (a==0) { Setting=0; } else { Setting=1; }
var b=p.getnamed(“buttonOnOff”);
b.message(“text”, textvalues[a]);


Nov 21, 2012 at 7:50pm

Thanks so much! I had tried that, but I realize now that I’d forgotten to include the “text” argument. D’oh! So simple.
Thanks again.

Nov 21, 2012 at 7:55pm

Alternately, you can set the attr like this:



Nov 22, 2012 at 3:59am

Thanks again. That’s very helpful.


You must be logged in to reply to this topic.