Changing a box size in presentation view


    Jan 20 2011 | 11:10 pm
    This only works in regular view. How do I make this work in presentation view?
    function list(a) { if(isNaN(this.patcher.parentpatcher)==0){return;} var myrect =this.patcher.box.rect; var width = arguments[0]; var height = arguments[1]; myrect[2] = myrect[0]+width; myrect[3] = myrect[1]+height; this.patcher.box.rect = myrect; post("resizing bcanvas to",myrect); post(); }
    Georg

    • Jan 20 2011 | 11:24 pm
      I do this outside js with a presentation_size message or with a presentation_rect message...
    • May 18 2022 | 5:34 am
      Anyone else has a solution for this? Working from the outside doesn't work from me I'm dealing with a library of bpatchers. I already can resize them dynamically with this.patcher.box.rect but I can't find the equivalent message so that this resize also applies in presentation mode. Any ideas? Thanks !
    • May 18 2022 | 7:33 am
      For whatever reason you have to work with a scripting message for pres mode positioning of bpatchers:
      var boxpos = new Array(4); boxpos[0] = 50 boxpos[1] = 50 boxpos[2] = 150 boxpos[3] = 150 this.patcher.message("script", "sendbox", "scrname", "presentation_rect", boxpos);
      You can also set "presentation_size" or "presentation_position" using only two values.
    • May 18 2022 | 1:31 pm
      Thank you @11OLSEN ! I just tried (unsuccessfully) to integrate this. I'm not sure what I'm missing.
      I put this in a js object, inside the test abstraction I call with my bpatcher. function bang() { post("sent a bang"); var boxpos = new Array(4); boxpos[0] = 50 boxpos[1] = 50 boxpos[2] = 150 boxpos[3] = 150 this.patcher.message("script", "sendbox", "scrname", "presentation_rect", boxpos); }
      Now from the outside (in my main patch, which contains the bpatcher), I switch to presentation mode, click the bang inside the bpatcher but nothing happens.
      Could you maybe give me a small example patch or show me what I'm missing?? Now I'm worried about the "scrname" part, is that a variable I don't know about or should I give the bpatcher an explicit name?... That would be kind of a deal breaker for me. I'm making a bpatcher library i.e. all my objects can be called many times. I can't really expect users to add a scripting name for each instance for this to work... :(
    • May 18 2022 | 1:50 pm
      If you are inside the bpatcher you have to add "parentpatcher". That's the one containing and scripting the bpatcher. And you could assign random names automatically to get around the varname problem.
      
      function bang()
      {
      	post("sent a bang");
      
      	var thevarname = this.patcher.box.varname;
      	// making sure the bpatcher has a scripting name 
      	if (thevarname=="")
      		this.patcher.box.varname = thevarname = "bp" + Math.floor(Math.random() * Date.now());
      	
       	var boxpos = new Array(4);
      	boxpos[0] = 50
      	boxpos[1] = 50
      	boxpos[2] = 150
      	boxpos[3] = 150
      	this.patcher.parentpatcher.message("script", "sendbox", thevarname, "presentation_rect", boxpos);
      }
    • May 18 2022 | 2:23 pm
      Wow excellent thank you so much it works now. I had no idea you could assign a varname from the inside like this, pretty slick !
    • May 18 2022 | 2:49 pm
      Sorry , I realize there's something else I'm missing here. Do you know by any chance how I can retrieve the curent presentation rect of the bpatcher, also from the inside? I tried adding this line I found on an older topic outlet(0,this.patcher.getattr("presentation_rect")); but it returns something strange like this js -1407374883553280
      Do you know another way to do this by any chance? My toggling system circles between different sizes of the bpatcher (to hide/reveal settings for instance) and I need to keep the object's location for it to work properly.
    • May 18 2022 | 3:01 pm
      this.patcher.box.rect will give you the right values depending on which view you are in.