cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
SDF1
Super User

JSL help: Can Outline Boxes be assigned functions?

Hi All,

 

  I was working on coding for a different subject when I needed to search the community for some support, but I came across this post from many years ago and it got me wondering, could it be done (there was no solution to the original post)? Can Outline boxes be assigned a function so that depending on their open/close state, it will close/open other outline boxes? If another outline box is opened, can the window automatically update to close all other outline boxes, except the one that was just opened?

 

  I tried several different approaches, and although you can define a function within an outline box, see the example below. You apparently can't refer to another outline box within the function call (JMP complains about a deleted reference to the other outline boxes), and Outline Box() doesn't accept the send command <<Set Function(Function({this}, script)).

Names Default To Here( 1 );

w = New Window( "My Window", 

	A = Outline Box( "Panel Box A",
		H List Box( Button Box( "A1" ), Button Box( "A2" ), Button Box( "A3" ) ),
		AFunc = Function( {this},
			x = this + 2;
			Show( x );
		);
		AFunc( 7 );
	),
	B = Outline Box( "Panel Box B", H List Box( Button Box( "B1" ), Button Box( "B2" ), Button Box( "B3" ) ), <<Close( 1 ) ),
	C = Outline Box( "Panel Box C", H List Box( Button Box( "C1" ), Button Box( "C2" ), Button Box( "C3" ) ), <<Close( 1 ) )
);

The above script gives the following output:

DiedrichSchmidt_0-1637335076728.png

It clearly generates the desired window and displays the output of the function, which is x=9. But, I was unsuccessful in trying to create a function within the Outline Box that accessed the state of another Outline Box and dynamically closed/opened accordingly.

 

In short, the answer to my above question (and the original post) is No (or at least not yet, or also at least that I've found a way to do so). The long answer is more fun, and is Yes (mostly, with a workaround).

 

Something that is very close to what the original post was requesting is in the below code where I add some "prev" and "next" button boxes that will close the current Outline Box and then open the previous (cyclical) or next Outline Box. So, it's not technically the desired solution, but it accomplishes (more or less) what is needed.

 

The only downside is that you can't skip from let's say having Outline Box A open to opening Outline Box C and it dynamically updates the window by closing all other Outline Boxes, except C. I can imagine some situations where having this functionality to an Outline Box would be very helpful. Maybe it could be a future feature in new releases of JMP?

 

Anyway, I thought the original post was interesting and wanted to investigate that path a little before getting back to my other work.

 

Thanks!,

DS

 

Code for the "workaround":

Names Default To Here( 1 );

w = New Window( "My Window", 

	A = Outline Box( "Outline Box A",
		V List Box(
			H List Box( Button Box( "A1" ), Button Box( "A2" ), Button Box( "A3" ) ),
			H List Box(
				Button Box( "prev",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Close( 1 );
							B << Close( 1 );
							C << Set Open( 1 );
						)
					)
				),
				Button Box( "next",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Close( 1 );
							B << Set Open( 1 );
							C << Close( 1 );
						)
					)
				)
			)
		)
	),
	B = Outline Box( "Outline Box B",
		V List Box(
			H List Box( Button Box( "B1" ), Button Box( "B2" ), Button Box( "B3" ) ),
			H List Box(
				Button Box( "prev",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Set Open( 1 );
							B << Close( 1 );
							C << Close( 1 );
						)
					)
				),
				Button Box( "next",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Close( 1 );
							B << Close( 1 );
							C << Set Open( 1 );
						)
					)
				)
			)
		),
		<<Close( 1 )
	),
	C = Outline Box( "Outline Box C",
		V List Box(
			H List Box( Button Box( "C1" ), Button Box( "C2" ), Button Box( "C3" ) ),
			H List Box(
				Button Box( "prev",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Close( 1 );
							B << Set Open( 1 );
							C << Close( 1 );
						)
					)
				),
				Button Box( "next",
					<<Style( "Underline" ),
					<<Set Function(
						Function( {},
							A << Set Open( 1 );
							B << Close( 1 );
							C << Close( 1 );
						)
					)
				)
			)
		),
		<<Close( 1 )
	)
);
6 REPLIES 6
jthi
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

You might be able to do it with either using XPath or some combination of <<Top parent, <<Parent, << Sib, << Prev Sib and so on.

 

Some examples to get you possible started:

Names Default To Here(1);

func_prev = Function({this},
	((this << Parent) << parent) << Close(1);
	(((btn_prev << parent) << parent) /*current*/ << prev sib) << Close(0);
);

func_next = Function({this},
	((this << Parent) << parent) << Close(1);
	(((this << Parent) << parent) << sib) << Close(0);
);

nw = New Window("My Window", 
	Outline Box("Panel Box A",
		H List Box(Button Box("A1"), Button Box("A2"), Button Box("A3")),
		H List Box(
			Button Box("prev", <<Style("Underline"), <<Set Function(Function({this}, func_prev(this)))),
			btn_next = Button Box("next", <<Style("Underline"), <<Set Function(Function({this}, func_next(this)))),
		)
	),
	Outline Box("Panel Box B", << Close(1),
		H List Box(Button Box("B1"), Button Box("B2"), Button Box("B3")),
		H List Box(
			btn_prev = Button Box("prev", <<Style("Underline"), <<Set Function(Function({this}, func_prev(this)))), 
			Button Box("next", <<Style("Underline"), <<Set Function(Function({this}, func_next(this)))),
		)
	),
	Outline Box("Panel Box C", << Close(1),
		H List Box(Button Box("C1"), Button Box("C2"), Button Box("C3")),
		H List Box(
			Button Box("prev", <<Style("Underline"), <<Set Function(Function({this}, func_prev(this)))),
			Button Box("next", <<Style("Underline"), <<Set Function(Function({this}, func_next(this)))),
		)
	),
);


stop(); nw << XPath("//OutlineBox"); //get all outline boxes nw << XPath("//OutlineBox[@isOpen='true']"); //get all open nw << XPath("//OutlineBox[@isOpen='false']"); //get all closed (nw << XPath("//OutlineBox[@isOpen='true']")) << Close(1); //close all open (nw << XPath("//OutlineBox[@isOpen='false']")) << Close(0); //open all closed
-Jarmo
txnelson
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

You can specify an On Close() function for outline boxes.  

Jim
SDF1
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

Hi @txnelson ,

 

  But isn't the On Close() function for when windows close? What was originally looked after is more for On Open or On Close function of a Outline Box.

 

  Maybe future JMP versions will add some similar kind of functionality to the Outline Boxes.

 

Thanks!,

DS

jthi
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

So you would want to work only with Outline Boxes, no buttons, in such a manner that when you open other outline box, all other outline boxes (the only one open) would be closed? Quickly going through some documentation, didn't find a way to do this without some workaround with button or red triangle menu option.

-Jarmo
SDF1
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

Hi @jthi ,

 

  Yes, that was the goal of the original post I came across from 2009. I thought the idea was interesting and worth attempting to solve, but as you've noted, it's not possible without doing some kind of workaround with buttons or red triangle. Apparently, Outline Boxes are not objects that can be assigned a direct functionality. I believe the workaround is the best that we can get for the time being, at least.

 

Thanks!,

DS

SDF1
Super User

Re: JSL help: Can Outline Boxes be assigned functions?

Hi @jthi ,

 

  Thanks for your feedback and thoughts. The last section of my code that posted also does basically the same thing as your suggestions, allows the user to cyclically move through the different Outline Boxes. Unfortunately, there is not yet a solution that dynamically assesses the state of an Outline Box and then changes the other Outline Boxes in response.

 

Thanks!,

DS