Forums > MaxMSP

presets and jsui

February 10, 2008 | 9:53 pm

Hi

is there a reasonably easy solution to save presets for jsui elements? Below I have a patch for storing and wiping presets which for a toggle on/off. There is also a jsui toggle but preset does not work with jsui – is there a way to retrigger its saved state and the tings it effected? Thanks in advance

a+
gar

max v2;
#N vpatcher 10 59 747 556;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 14 105 44 196617 clearall;
#P toggle 60 157 15 0;
#P user jsui 120 176 28 15 1 0 0 jsui_texttoggle.js On Off 100 100 100 240 240 240 "Gill sans" 0.7 0.25 2;
#P newex 146 104 43 196617 route 0;
#P message 190 105 46 196617 store $1;
#P user ubumenu 60 104 85 196617 0 1 1 0;
#X add Record preset;
#X add 1;
#X add 2;
#X add 3;
#X add 4;
#X add 5;
#X add 6;
#X add 7;
#X add 8;
#X add 9;
#X add 10;
#X add 11;
#X add 12;
#X add 13;
#X add 14;
#X add 15;
#X add 16;
#X prefix_set 1 1 text 0;
#N vpreset 3;
#X append 1 1 5 157 60 toggle int 0 ;;
#X append 2 1 5 157 60 toggle int 1 ;;
#P preset 60 131 173 17;
#P connect 6 0 0 0;
#P hidden connect 2 0 0 0;
#P connect 0 0 5 0;
#P hidden connect 1 0 3 0;
#P hidden connect 3 1 2 0;
#P pop;


February 10, 2008 | 10:15 pm

On 10 Feb 2008, at 21:53, Garrett Lynch wrote:

> is there a reasonably easy solution to save presets for jsui elements?

Almost certainly not.

If you want to use the (deprecated) preset machinery with js or jsui,
your only option is to surround the object with "real" Max objects and
bind the preset to these.

If you use the pattr machinery, you are responsible for saving and
restoring state to/from JavaScript: this state is an array of atoms,
so it’s possible to encode fairly complex data structures.

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net



jln
February 10, 2008 | 10:25 pm


February 10, 2008 | 11:22 pm

hi

I keep getting stack overflows when I use the hidden toggle solution. Going to have a look at pattrstorage as I’ve not used it before. Thanks.

a+
gar



kjg
February 11, 2008 | 2:43 am

I think a set message fixes the stack overflow:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 130 118 32 196617 print;
#N vpreset 2;
#X append 1 2 0 80 83 toggle int 0 ;;
#X append 2 2 0 80 83 toggle int 1 ;;
#P preset 136 182 47 27;
#P hidden message 83 63 39 196617 set $1;
#P user jsui 130 63 93 33 1 0 0 jsui_texttoggle.js zero one 230 230 30 30 120 30;
#P hidden toggle 83 80 15 0;
#P hidden connect 1 0 2 0;
#P hidden connect 2 0 0 0;
#P hidden connect 0 0 1 0;
#P connect 1 0 4 0;


February 11, 2008 | 7:38 pm

this seems fine to me, I’ve seen far less elegant solutions – thanks for that, finished test below.

a+
gar

max v2;
#N vpatcher 469 204 1206 701;
#P window setfont "Sans Serif" 9.;
#P message 79 211 39 196617 set $1;
#P user jsui 126 211 93 33 1 0 0 jsui_texttoggle.js zero one 230 230 30 30 120 30;
#P toggle 79 228 15 0;
#P message 14 105 44 196617 clearall;
#P toggle 47 227 15 0;
#P newex 146 104 43 196617 route 0;
#P message 190 105 46 196617 store $1;
#P user ubumenu 60 104 85 196617 0 1 1 0;
#X add Record preset;
#X add 1;
#X add 2;
#X add 3;
#X add 4;
#X add 5;
#X add 6;
#X add 7;
#X add 8;
#X add 9;
#X add 10;
#X add 11;
#X add 12;
#X add 13;
#X add 14;
#X add 15;
#X add 16;
#X prefix_set 1 1 text 0;
#N vpreset 3;
#X append 1 1 6 228 79 toggle int 0 ; 4 227 47 toggle int 0 ;;
#X append 2 1 6 228 79 toggle int 1 ; 4 227 47 toggle int 1 ;;
#P preset 60 131 173 17;
#P connect 0 0 4 0;
#P connect 2 0 0 0;
#P connect 5 0 0 0;
#P connect 7 0 8 0;
#P connect 0 0 6 0;
#P connect 8 0 6 0;
#P connect 6 0 7 0;
#P connect 1 0 3 0;
#P connect 3 1 2 0;
#P pop;


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