cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
shaultz
Level II

In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Hi,

I click on a box in a hierarchical diagram.

How can I know (using JSL) which box has been selected?

Thanks.

Shaul. 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
ian_jmp
Level X

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

As I said already, I'm not sure what behaviour you are looking for nor, at a higher level, of what you want to acomplish (there's almost always more than one way to deliver the desired functionality). Not knowing the latter, this slight modification of the example above may or may not help.

Names Default To Here( 1 );

Diagram(
	hierarchy(
		Hier Box(
			bb1 = Button Box( "Great Grand Parent", Speak(bb1<<getButtonName), <<underlineStyle ),
			Hier Box(
				bb2 = Button Box( "Grand Parent 1", Speak(bb2<<getButtonName), <<underlineStyle ),
				Hier Box( bb3 = Button Box( "Parent 1", Speak(bb3<<getButtonName), <<underlineStyle ), ),
				Hier Box( bb4 = Button Box( "Parent 2", Speak(bb4<<getButtonName), <<underlineStyle ) ),

			),
			Hier Box(
				bb5 = Button Box( "Grand Parent 2", Speak(bb5<<getButtonName), <<underlineStyle ),
				Hier Box(
					bb6 = Button Box( "Parent 3", Speak(bb6<<getButtonName), <<underlineStyle ),
					Hier Box( bb7 = Button Box( "Child 1", Speak(bb7<<getButtonName), <<underlineStyle ) ),
					Hier Box( bb8 = Button Box( "Child 2", Speak(bb8<<getButtonName), <<underlineStyle ) )
				),
				Hier Box( bb9 = Button Box( "Parent 4", Speak(bb9<<getButtonName), <<underlineStyle ) )
			)
		)
	)
);

View solution in original post

shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

OK! it works. Thanks a lot. Here's the JSL that swiches "h2" on and off.

namesdefaulttohere(1);
shw2=1;
w=newwindow("w",
	h1=hierbox("h1",
		b2=buttonbox("b2",
				shw2=1-shw2;
				h2<<visibility(
					if(shw2==0,
						"hidden",
						"visible"	
					)
				)
					
		),
		h2=hierbox("h2",
			h3=hierbox("h3")
		)
	)
);
h1<<ChangeType("hierarchy");

View solution in original post

11 REPLIES 11
ian_jmp
Level X

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Probably more details are required to give a sensible response. How, exactly, did you generate the diagram, please?

shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Here's a simple code:

w=newwindow("w",
	h1=hierbox("h1",
		h2=hierbox("h2",
			h3=hierbox("h3")
		)
	)
);

 

Now, when I get the diagram and click on one of the boxes, I'd like to know exactly which box has been selected.

Thanks.

 

shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Of course, My question referes to an automatic identification by JSL

shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

I'd like to make my point clear.

Suppose I create a diagram. In that diagram, I 'd like to hide any selected box.

I could do it if I had something like "Is Selected" property of the HierBox which, it seems, I don't have.

So I will demonstrate the idea as if I could have a variable (shw) indicating the selection of "h2" (HierBox #2):

shw=1;
w=newwindow("w",
	h1=hierbox("h1",
		h2=hierbox("h2",
			<<visibility(
				if(shw==0,
					"hidden",
					"visible"	
				)
			),
			h3=hierbox("h3")
		)
	)
);

Since shw=1, the diagram is completely shown, However, shw=0, "h2" and "h3" are hidden and only "h1" is shown..

ian_jmp
Level X

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

I'm not quite sure what behaviour you want. But it might be possible to take this kind of approach, where 'doSomething()' makes changes to the display tree. If you are removing or hiding nodes then I guess you would need another button to restore them.

 

Names Default To Here( 1 );

doSomething = Expr( Beep() );

Diagram(
	hierarchy(
		Hier Box(
			Button Box( "Great Grand Parent", doSomething, <<underlineStyle ),
			Hier Box(
				Button Box( "Grand Parent 1", doSomething, <<underlineStyle ),
				Hier Box( Button Box( "Parent 1", doSomething, <<underlineStyle ), ),
				Hier Box( Button Box( "Parent 2", doSomething, <<underlineStyle ) ),

			),
			Hier Box(
				Button Box( "Grand Parent 2", doSomething, <<underlineStyle ),
				Hier Box(
					Button Box( "Parent 3", doSomething, <<underlineStyle ),
					Hier Box( Button Box( "Child 1", doSomething, <<underlineStyle ) ),
					Hier Box( Button Box( "Child 2", doSomething, <<underlineStyle ) )
				),
				Hier Box( Button Box( "Parent 4", doSomething, <<underlineStyle ) )
			)
		)
	)
);
shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Thanks. However, I didn't understand how to extract the identification of the box (slected or clicked).

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Select Help > Scripting Index. Change browser to show Display Boxes. Select HierBox in the first list. I do not find anything in the proctocol for this object that directly addresses your need.

 

You can also use Show Properties( HierBox() ) and examine the Log.

 

This object is self-contained in the case of editing actions. None of the editing or change states are surfaced to JSL.

shaultz
Level II

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

Thanks. Indeed there is no direct way to address my need.

However, I will redefine my need, maybe for the developers of JMP, for future versions:

The need is to be able to open or to close parts of a diagram, just like it can be doen with OUTLINEBOXes.

Again, Thank you both.

ian_jmp
Level X

Re: In JSL, is it possible to identify a selected (or clicked-on) box in a diagram?

As I said already, I'm not sure what behaviour you are looking for nor, at a higher level, of what you want to acomplish (there's almost always more than one way to deliver the desired functionality). Not knowing the latter, this slight modification of the example above may or may not help.

Names Default To Here( 1 );

Diagram(
	hierarchy(
		Hier Box(
			bb1 = Button Box( "Great Grand Parent", Speak(bb1<<getButtonName), <<underlineStyle ),
			Hier Box(
				bb2 = Button Box( "Grand Parent 1", Speak(bb2<<getButtonName), <<underlineStyle ),
				Hier Box( bb3 = Button Box( "Parent 1", Speak(bb3<<getButtonName), <<underlineStyle ), ),
				Hier Box( bb4 = Button Box( "Parent 2", Speak(bb4<<getButtonName), <<underlineStyle ) ),

			),
			Hier Box(
				bb5 = Button Box( "Grand Parent 2", Speak(bb5<<getButtonName), <<underlineStyle ),
				Hier Box(
					bb6 = Button Box( "Parent 3", Speak(bb6<<getButtonName), <<underlineStyle ),
					Hier Box( bb7 = Button Box( "Child 1", Speak(bb7<<getButtonName), <<underlineStyle ) ),
					Hier Box( bb8 = Button Box( "Child 2", Speak(bb8<<getButtonName), <<underlineStyle ) )
				),
				Hier Box( bb9 = Button Box( "Parent 4", Speak(bb9<<getButtonName), <<underlineStyle ) )
			)
		)
	)
);