jsui + pattr = strangeness…

May 31, 2007 at 11:52pm

jsui + pattr = strangeness…

I have a simple patcher example that binds a jsui label to
a pattr and then tries to set its text. I see no bind error messages.
But for some reason it will not do it. Can someone explain what
might be the problem…

Thanks,
Anthony

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 531 409 1131 809;
#P window setfont “Sans Serif” 9.;
#P message 197 64 40 9109513 text bar;
#P newex 197 88 125 9109513 pattr @bindto parent::lblTitle;
#P objectname u478000001;
#P connect 1 0 0 0;
#P pop 1;
#P newobj 231 107 66 9109513 p inside_here;
#P objectname inside_here;
#P user jsui 87 56 358 27 1 0 0 jsui_roundedlabel.js foo;
#P objectname lblTitle;
#P window clipboard copycount 2;

#32219
Jun 1, 2007 at 8:43am

This is not the way pattr works. You can’t use pattr to send any message to an object, only set its value. Not all objects support binding. This jsui doesn’t, but it will if you define a set/getvalueof() method. That way you could set the label text with pattr.

In this case, I too would expect an error message when binding the pattr to the jsui (because the jsui doesn’t support pattr bindings).

Mattijs

Quote: Anthony Palomba wrote on Fri, 01 June 2007 01:52
—————————————————-
> I have a simple patcher example that binds a jsui label to
> a pattr and then tries to set its text. I see no bind error messages.
> But for some reason it will not do it. Can someone explain what
> might be the problem…
>
>
>
> Thanks,
> Anthony
>
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #N vpatcher 531 409 1131 809;
> #P window setfont “Sans Serif” 9.;
> #P message 197 64 40 9109513 text bar;
> #P newex 197 88 125 9109513 pattr @bindto parent::lblTitle;
> #P objectname u478000001;
> #P connect 1 0 0 0;
> #P pop 1;
> #P newobj 231 107 66 9109513 p inside_here;
> #P objectname inside_here;
> #P user jsui 87 56 358 27 1 0 0 jsui_roundedlabel.js foo;
> #P objectname lblTitle;
> #P window clipboard copycount 2;
>
>
>
>
—————————————————-

#105602
Jun 1, 2007 at 9:04am

jsui_roundedlabel.js doesn’t have getvalueof() or setvalueof()
methods (check out the pattr sdk in the general Max SDK for more
info). You are trying to send an arbitrary message to the object, in
any case, so why not use pattrforward. That’s what it’s for:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#N vpatcher 531 409 1131 809;
#P window setfont “Sans Serif” 9.;
#P message 250 58 46 196617 text foo;
#P message 194 59 47 196617 text bar;
#P newex 197 88 142 196617 pattrforward parent::lblTitle;
#P objectname u296000001;
#P connect 2 0 0 0;
#P connect 1 0 0 0;
#P pop 1;
#P newobj 291 167 66 196617 p inside_here;
#P objectname inside_here;
#P user jsui 147 116 358 27 1 0 0 jsui_roundedlabel.js foo;
#P objectname lblTitle;
#P window clipboard copycount 2;

Am 01.06.2007 um 01:52 schrieb Anthony Palomba:

> I have a simple patcher example that binds a jsui label to
> a pattr and then tries to set its text. I see no bind error messages.
> But for some reason it will not do it. Can someone explain what
> might be the problem…

#105603
Jun 1, 2007 at 9:13am

Because the jsui object itself DOES support pattr bindings, and
because pattr is dumb as a rock, the binding functions. If the script
in the jsui were swapped out for a script which did support get/
setvalueof, everything would work swimmingly.

I am not in favor of an error message in this case. If you’re smart
enough to use javascript, you’re smart enough to read the pattr SDK
and troubleshoot the missing get/setvalueofness. ;)

jb

Am 01.06.2007 um 10:43 schrieb Mattijs Kneppers:

> In this case, I too would expect an error message when binding the
> pattr to the jsui (because the jsui doesn’t support pattr bindings).

#105604
Jun 1, 2007 at 9:26am

Honestly, I don’t think it is harmful to anyone to throw an error if there is no set/getvalueof in the js when pattr sends it something..

Error messages are not only for dumb people but also a tool to speed up the work of smart people ;)

Mattijs

Quote: Jeremy Bernstein wrote on Fri, 01 June 2007 11:13
—————————————————-
> Because the jsui object itself DOES support pattr bindings, and
> because pattr is dumb as a rock, the binding functions. If the script
> in the jsui were swapped out for a script which did support get/
> setvalueof, everything would work swimmingly.
>
> I am not in favor of an error message in this case. If you’re smart
> enough to use javascript, you’re smart enough to read the pattr SDK
> and troubleshoot the missing get/setvalueofness. ;)
>
> jb
>
> Am 01.06.2007 um 10:43 schrieb Mattijs Kneppers:
>
> > In this case, I too would expect an error message when binding the
> > pattr to the jsui (because the jsui doesn’t support pattr bindings).
>
>
—————————————————-

#105605
Jun 1, 2007 at 9:38am

Let me put it another way: it’s not going to change. It’s too much
extra work to support one object which functions in a special way
(scripts within objects which may or may not support certain
methods). At such time that we have a language-binding API and
support this sort of stuff on a general level, I’d be willing to add
the extra check, but pattr has enough to do already.

jb

Am 01.06.2007 um 11:26 schrieb Mattijs Kneppers:

>
> Honestly, I don’t think it is harmful to anyone to throw an error
> if there is no set/getvalueof in the js when pattr sends it
> something..
>
> Error messages are not only for dumb people but also a tool to
> speed up the work of smart people ;)
>
> Mattijs

#105606
Jun 1, 2007 at 9:43am

Quote: Jeremy Bernstein wrote on Fri, 01 June 2007 11:38
—————————————————-
> Let me put it another way: it’s not going to change. It’s too much
> extra work to support one object which functions in a special way
> (scripts within objects which may or may not support certain
> methods). At such time that we have a language-binding API and
> support this sort of stuff on a general level, I’d be willing to add
> the extra check, but pattr has enough to do already.

Ah, of course. I was just being theoretical there. I agree that the priority isn’t very high.

Mattijs

>
> jb
>
> Am 01.06.2007 um 11:26 schrieb Mattijs Kneppers:
>
> >
> > Honestly, I don’t think it is harmful to anyone to throw an error
> > if there is no set/getvalueof in the js when pattr sends it
> > something..
> >
> > Error messages are not only for dumb people but also a tool to
> > speed up the work of smart people ;)
> >
> > Mattijs
>
—————————————————-

#105607

You must be logged in to reply to this topic.