cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
AlterEgo
Level II

Self-reference in the hot-spot script ("Set Menu Script"). Is it possible?

Hi,

 

is self-reference possible in the hot-spot commands ("<< Set Menu Script"), similar to "<<Set Function".

E.g., in the example below I'd like to have a hot-spot commands instead of the buttons:

 

Names Default To Here( 1 );

names = {"AAAA", "BBBB", "CCCC", "DDDD"};

New Window( "Example",
	For( i = 1, i <= N Items( names ), i++,
		<<append(
			Outline Box( names[i], Button Box( "Show my name", <<Set Function( Function( {self}, Show( (self << parent) << get title ) ) ) ), )
		)
	)
);

 What I'd like to have is something like below:

 

New Window( "Example",
	For( i = 1, i <= N Items( names ), i++,
		<<append(
			Outline Box( names[i],
				<<Set Menu Script(
					{ "Show my name", <function with reference to self here> },
				)
			)
		)
	)
);

Assigning each outline box to variable is not an option. I need to be able to do it dynamically. Any ideas?

 

 

Thanks

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Self-reference in the hot-spot script ("Set Menu Script"). Is it possible?

Not sure if there is anything like << set function for outline boxes and their context menu, but you can use Eval(EvalExpr()) (or other methods, Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute ) for quite similar effect

Names Default To Here(1);

names = {"AAAA", "BBBB", "CCCC", "DDDD"};
vlb = V List Box();

For Each({name}, names,
	vlb << append(ob = Outline Box(name));
	Eval(EvalExpr(ob << Set Menu Script(
		{"Show my name", Show(Expr(ob) << get title)}
	)));
);

nw = New Window( "Example", vlb);

(nw << XPath("//OutlineBox")) << Get Menu Script;
-Jarmo

View solution in original post

AlterEgo
Level II

Re: Self-reference in the hot-spot script ("Set Menu Script"). Is it possible?

Thanks! Excellent, just what I need.

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Self-reference in the hot-spot script ("Set Menu Script"). Is it possible?

Not sure if there is anything like << set function for outline boxes and their context menu, but you can use Eval(EvalExpr()) (or other methods, Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute ) for quite similar effect

Names Default To Here(1);

names = {"AAAA", "BBBB", "CCCC", "DDDD"};
vlb = V List Box();

For Each({name}, names,
	vlb << append(ob = Outline Box(name));
	Eval(EvalExpr(ob << Set Menu Script(
		{"Show my name", Show(Expr(ob) << get title)}
	)));
);

nw = New Window( "Example", vlb);

(nw << XPath("//OutlineBox")) << Get Menu Script;
-Jarmo
AlterEgo
Level II

Re: Self-reference in the hot-spot script ("Set Menu Script"). Is it possible?

Thanks! Excellent, just what I need.