Binding to an object in the patcher...

    Jun 03 2013 | 7:06 pm
    Hi, is there anyway I can bind to a control in patcher so that I can see when the value has changed instead of having to take the output from the control and send it into the js?
    thx Lee

    • Jun 19 2013 | 11:41 pm
      Hi, anyone got any info on this, one way or t'other? thx
    • Aug 12 2013 | 11:46 pm
      anyone? :)
    • Aug 13 2013 | 5:32 am
      Is your objective to have nothing attached to the inlet of your js object, or do you just want to bind to something that's not directly connected to your js object but you could tolerate having a pattr object attached to it? If the latter, then it's feasible. If the former, I'm not so sure.
    • Aug 13 2013 | 7:22 pm
      latter is fine... i tried with a pattr but couldn't figure it out...
      basically there's about 15 controls in a "cell" - rather than taking the output of each, doing a prepend with an id and sending it into the inlet, I'd like to shortcut and just get the JS to be notified when any of the 15 controls changes....
    • Aug 14 2013 | 3:44 am
      Well then, I think you could do something along these lines (times 15).
      Here's some js code you should save in a file called objectinfo.js.
      inlets = 1; outlets = 1; autowatch = 1;
      var mypatcher = this.patcher; var mynumberbox = mypatcher.getnamed("mynumberbox"); var mynumber;
      function showit() { if (mynumberbox.valid) { mynumberbox.message("int", mynumber); } }
      function setit(x) { mynumber = x; }
      function setvalueof(x) { mynumber = x; post("something changed\n"); }
      And here's a patch to test it.
    • Aug 14 2013 | 3:47 am
      So, as you suggested, you could tag each of your UI object values with an ID tag before sending it into the pattr setit, and then store all the values inside your js object.
    • Aug 14 2013 | 3:48 am
      Disclaimer: There may well be a better solution than this, but this is the best I can think up at the moment.
    • Aug 14 2013 | 4:51 am
      And isn't this just as good, and more 'normal'?
      Save this code as 'holdvalues.js': inlets = 1; outlets = 1; autowatch = 1;
      var thevalues = new Array();
      function setvalue(x,y) { thevalues[x]=y; post("something changed\n"); }
      function getvalue(x) { outlet(0, thevalues[x]); }
      And then test it with this patch:
    • Aug 14 2013 | 9:03 am
      Hey, thanks Chris... will check this out tonight :)
    • Aug 20 2013 | 7:39 am
      Every GUI object (e.g. flonum, umenu etc.) understands getvalueof() and setvalueof(). Since this is not documented, it might be subject of change in later max versions.