cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
nguyendv0610
Level III

Trouble Closing Button Box window after button was already pressed

My launchWin window consist of interactive button boxes. However when I press the button, the window will not close. Im not sure why. I thought the button is supposed to close automatically after being clicked on

I have the below Code: 



//Set the working table as the current table, pay attention to which table is at the top
dt = currentdatatable();

//Create a summary of the total aliquots in each box by BOX ID
sumdt = dt << Summary(
Group( :BOX ID ),
Sum( :Name( "# of aliquots" ) ),
Freq( "None" ),
Weight( "None" )
);
//Calculate Free Space in each box and assign to new col
col5 = sumdt << New Column("FreeSpace", Data Type (Numeric),
Formula(
96 - :Name("Sum(# of aliquots)")

)
);
//sort new table by new col
sumdt << Sort(By(:FreeSpace), Order(Descending), Replace Table);

box10 = sumdt[index(1,10), 1];
row10 = sumdt[index(1,10), 4];
close(sumdt, nosave);

 

 

launchWin = New Window( "Launcher",
<<Modal,
V List Box(

Lineup Box( N Col( 4 ), Spacing( 20 ),

//Check for Free space
Button Box( "Check Space",
New Window ("Available Spaces",
Table Box(
Number Col Box("Box ID", box10),
Number Col Box("Available Slot", row10)
)
)

),


//Cancel
Button Box( "Cancel", Throw( 1 ) )
),
)
);

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Trouble Closing Button Box window after button was already pressed

If the Button Box were named "OK", it would close automatically. But you've created your own button with its own name, which is perfectly fine, but the custom button will only do what you tell it to do.

 

There's two ways to add the ability to close a button's window. One is to assign the Button Box to a variable, and then send it the Close Window message within the button's script:

 

b=Button Box( "Check Space",
	New Window( "Available Spaces",
		Table Box( Number Col Box( "Box ID", box10 ), Number Col Box( "Available Slot", row10 ) )
	);
	b<<Close Window;
)

Or you can assign a function to the button and avoid adding a variable to the global namespace:

Button Box( "Check Space",
	<<Set Function( Function( {this},
		New Window( "Available Spaces",
			Table Box( Number Col Box( "Box ID", box10 ), Number Col Box( "Available Slot", row10 ) )
		);
		this<<Close Window
	))
)

HTH,

Melanie

View solution in original post

2 REPLIES 2

Re: Trouble Closing Button Box window after button was already pressed

If the Button Box were named "OK", it would close automatically. But you've created your own button with its own name, which is perfectly fine, but the custom button will only do what you tell it to do.

 

There's two ways to add the ability to close a button's window. One is to assign the Button Box to a variable, and then send it the Close Window message within the button's script:

 

b=Button Box( "Check Space",
	New Window( "Available Spaces",
		Table Box( Number Col Box( "Box ID", box10 ), Number Col Box( "Available Slot", row10 ) )
	);
	b<<Close Window;
)

Or you can assign a function to the button and avoid adding a variable to the global namespace:

Button Box( "Check Space",
	<<Set Function( Function( {this},
		New Window( "Available Spaces",
			Table Box( Number Col Box( "Box ID", box10 ), Number Col Box( "Available Slot", row10 ) )
		);
		this<<Close Window
	))
)

HTH,

Melanie

nguyendv0610
Level III

Re: Trouble Closing Button Box window after button was already pressed

Thank you!