There is no way to make a Bpatcher and include in Presentation Mode?!?

startec's icon

If you create a bpatcher in javascript usinga = this.patcher.newdefault(10, 105, "bpatcher", "filename");
It will default to not appearing in presentation. To set the presentation value to 1 (or True / enabled), I have been using:a.message("presentation", 1);

This exact code works for many objects but it does not work for a Bpatcher? If it does not, is there any way to include a Bpatcher made from javascript in presentation mode (without using the inspector)?

Thanks

Lee's icon

Doing stuff with bpatchers is slightly different to normal objects, you need to send a message to the 'box'. i can't try this at the moment, but I think this should do it:

this.patcher.message( 'script', 'sendbox', 'bpatcher_name', 'presentation', 1 );

startec's icon

Wow - That is it. Combined with your answer on the other forum, I got it! Thanks a lot. One of the other issues is that since this.patcher.message('script', 'sendbox', 'bpatcher_name', 'presentation', 1);
requires the bPatcher to have a "varname" property, I had to set that.

Normally I have been setting properties as such: objVariable.message("varname", "happy");
but that does not work in bPatcher.

I had to use bpatcherVariable.varname = 'happiest'; Interestingly, this method does not work for something like a message box (where the .message() has to be used);

Can you explain to me why I can set the bPatcher varname property how I would in any JS code, but I have to "message" properties to other objects?

Also, might I ask how you knew about the this.patcher.message(a, b, c, d, e); code? I'm so happy it's working but I do not see that code or the "sendbox" argument anywhere in the documentation. Thanks

Lee's icon

Hi,

Can you explain to me why I can set the bPatcher varname property how I would in any JS code, but I have to “message” properties to other objects?

-- Sorry, not quite sure what you're asking here...?

Also, might I ask how you knew about the this.patcher.message(a, b, c, d, e); code? I’m so happy it’s working but I do not see that code or the “sendbox” argument anywhere in the documentation. Thanks

-- probably the same way as you back in the past - asking on the forum :) There is also this,

sendbox: Send a message to an object box. This message is identical to send except that it sends the message to an object's box rather than the object referred to by the box. There is currently only one object, bpatcher, in which the object and box are different objects. The box is a bpatcher, and the object is a patcher. What can you tell a bpatcher to do? One example is the boxborder message, which is equivalent to sending the border message to a thispatcher object in a patcher inside a bpatcher. Peek inside the Inspector patch for bpatcher for other ideas.

Syntax: script sendbox

Example: script sendbox bpbp boxborder 0

-- it's a bit cryptic but this is the same message that we are sending using the javascript.

startec's icon

Sorry for the lack of clarity. My question is: how come for most objects, properties are set like:

a = this.patcher.newdefault(10, 105, "message");
a.message("varname", "message_varname");

but for bPatcher the property is set in a different way (i.e.):
bPatcherVariable = this.patcher.newdefault(10, 105, "bpatcher", "filename");
bpatcherVariable.varname = 'happiest';

I actually prefer the .varname method as it is closer to javascript but so it only seems to work on a bpatcher object

My second question is more about this format this.patcher.message('script', 'sendbox', 'bpatcher_name', 'presentation', 1);

To break this down, what are the arguments? this.patcher.message sends a message to the script property (which I have never seen before) of the sendbox object, which is a property of the bpatcher_name and the message it sends is presentation, 1

Nowhere in the documentation do I see this. Mainly I am confused by the use of script and sendbox as I have only been using this.patcher.message with two arguments (I didn't think it could even take more).

Lee's icon

in the first case:
a.message("varname", "message_varname");
you can do:
a.varname = "message_varname";

so this is consistent - you should be able to access all properties in this way on the js objects.

in the second, if you read the excerpt I posted from the doc it does say "There is currently only one object, bpatcher, in which the object and box are different objects. The box is a bpatcher, and the object is a patcher". this is why we need to use sendbox to talk to the bpatcher.

using this.patcher.message sends a message to the target - this is not necessarily a property(attribute) - it's a message - open up the thispatcher reference and you'll see the first entry is script - then look further down and you'll see sendbox... i agree this stuff is a bit different to get your head round to start with, in a way you have to think of a bpatcher as 2 things at one - the actual bpatcher object itself and then what it contains and then you understand that you need to be able to address these things in 2 different ways