Forums > Javascript

Extracting the state of a toggle in JavaScript

March 5, 2010 | 2:11 pm

Is there a message that can be sent to a Javascript-created toggle to learn its current state (which may have been altered by the user)?

TiA,
Eric


March 5, 2010 | 3:29 pm

Assuming that you have a toggle somewhere in the patcher named "yoyo". You can use the pattr system to get it’s value using getvalueof.


function bang()
{
var toggle = this.patcher.getnamed("yoyo");
outlet(0, toggle.getvalueof());
}


March 5, 2010 | 5:22 pm

Outstanding. Thanks EJ!


July 26, 2011 | 3:11 am

the javascript documentation could be extended / improved a little bit more..

lets see what version 6 will bring to us!

any references / articles in this matter are always welcome!

happy patching guys!


July 26, 2011 | 3:12 am

duplicated, sorry


August 1, 2011 | 2:48 am

super cool, that was the little and important piece i was needing for my javascript toggle sequencer, i should post sources very soon ( :

tks guys!


August 1, 2011 | 2:53 am

the current version is attached.

yet super simple, build a grid of toggles than outputs bang when the playhead passes by a toggle set to ON.

need to improve it a bit to be really useful, but the main concept and code is pretty much there.

any feedbacks, suggestions, improvements, are more than welcome.

peace

Attachments:
  1. trigercreator.zip

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