jsui custom inspector patch


    Apr 25 2021 | 11:43 pm
    Under jsthis documentation there is a property about custom inspector page:
    Specific to the jsui object. The inspector property, if set to 1, causes Max to look for an inspector patch specific to your script rather than the default jsui-insp.pat file. (...)
    But I can't find any example or other documentation that would help understand how it is supposed to work. Does anyone have any insight into this?

    • Apr 26 2021 | 9:19 pm
      This is a legacy property that is no longer in use. We've removed it from the documentation for the next release.
    • Apr 26 2021 | 9:26 pm
      dOH! Thanks @Ben. :/
      Follow up question: Is there a way to expose some variables inside jsui to work as object attributes in Max?
    • Apr 26 2021 | 9:35 pm
      The one thing that is not currently supported is to specify the data type that the attribute accepts. There is an open feature request for that functionality.
    • Apr 26 2021 | 10:02 pm
      ah! Thanks @Ben.
      The one thing that is not currently supported is to specify the data type that the attribute accepts. There is an open feature request for that functionality.
      That would be really nice to have, I have a couple (soon-to-be)attributes that are just booleans and others are colors (4 float array). How can I get notifications about that feature? I mean, I always read the release notes, so I'll probably see it there, when released. FWIW, I'd like to say +1 for that feature! Thanks
    • Apr 26 2021 | 10:58 pm
      This is kind of a hacky but fun workaround by setting the attrui displaymode based on the incoming connection:
      var mode = 0.0;
      declareattribute("mode", "getmode", "setmode", 1);
      
      function setmode(v)
      {
      	init();
      	mode = v;
      }
      
      function getmode()
      {
      	return mode;
      }
      
      
      function init()
      {
      	box.patchcords.inputs.forEach(function(item) {
      		if (item.srcobject.maxclass == "attrui" && item.srcobject.displaymode != 2)
      			item.srcobject.setattr("displaymode", 2);
      	});
      }
    • Apr 27 2021 | 3:03 am
      wow, I would have not thought of this! Very hacky indeed. Thank you, @Ben :)
    • Apr 27 2021 | 3:23 am
      hackier and hackier So my problem now is that, with that code I need to change the parameter in attrui in order for it to change the display mode. When I tried moving the init() call to the setmode() function instead, Max crashes. The next problem will be, of course, how to put it back to auto. Because after this script change it gets stuck on that displaymode which cause other attributes to complain.