Here's a reworked example from Scripting Index:
Names Default To Here( 1 );
ob = Outline Box( "Picker",
{"Copy picture", ob << Copy Picture()},
H List Box( Text Box( "Label:" ), teb = Text Edit Box( Char( 213 ) ) )
);
New Window( "Example",
ob
);
It adds a menu item in the red triangle menu that would copy the picture of this box to the buffer.
Script works just fine.
My question is: what if I create my Outline Boxes dynamically, and I don't have a variable assigned to it.
How do I reference this Outline Box without variable? Something using keywords "this" or "self".
Something like this on the second box:
Names Default To Here( 1 );
vb = V List Box(
ob = Outline Box( "Picker",
{"Copy picture", ob << Copy Picture()},
H List Box( Text Box( "Label:" ), teb = Text Edit Box( Char( 213 ) ) )
),
Outline Box( "Picker",
{"Copy picture", this << Copy Picture()},
H List Box( Text Box( "Label number 2:" ), teb = Text Edit Box( Char( 213 ) ) )
);
);
New Window( "Example",
vb
);
There are good examples in Scripting Index for Set Function on number of Display Boxes:
Names Default To Here( 1 );
New Window( "Example",
Button Box( "press me", <<setFunction( Function( {thisBox}, thisBox << setButtonName( "thanks" ) ) ) )
);
But in this case we're not setting function, we're setting script, and this syntaxis doesn't work.
So, how do I accomplish this?