<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using another button instead of &amp;quot;Ok&amp;quot; - Modal windows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57886#M32190</link>
    <description>&lt;P&gt;You could just manually make the okay button and click it with btn &amp;lt;&amp;lt; Click.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;InputWindow = New Window( "Pick a file opening option (must be truncated)",
	&amp;lt;&amp;lt;modal, 
	
	V List Box(
		Text Box( "Pick a Cut and Truncated Waveform" ),
		Spacer Box( size( 1, 10 ) ),
		Button Box( "Open a file",
			path = Pick File(
				"Select Raw Waveform data",
				"", // no default directory
				{"JMP Files|jmp;jsl;jrn", "All Files|*"},
				1,
				0,
				"" // no default file
			);
			dt = Open( path ); //probably should do this instead of current data table()
			//dt = Current Data Table();
			btn_ok &amp;lt;&amp;lt; Click;
		),
		Spacer Box( size( 10, 1 ) ), 

		Button Box( "Select from a list",
			choose_data_table = Function( {},
				list = {};
				For( i = 1, i &amp;lt;= N Table(), i++,
					list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
				);

				win = New Window( "Select a data table",
					&amp;lt;&amp;lt;Modal,
					hb = H List Box(
						Panel Box( "Choose a data table",
							dt = List Box(
								list,
								max selected( 1 ),
								chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] );
								Show( chosen );
							)
						),

					)
				);
				chosen;
			);
			dt = choose_data_table();
			btn_ok &amp;lt;&amp;lt; Click;
		), 
		btn_ok = Buttonbox("OK")
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it sounds like you might not need a modal dialog.&amp;nbsp; You could just have the rest of your code execution be a function or expression and send that to each button.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;domorestuff = function({}, 
	print(dt);
);
InputWindow = New Window( "Pick a file opening option (must be truncated)",
	
	V List Box(
		Text Box( "Pick a Cut and Truncated Waveform" ),
		Spacer Box( size( 1, 10 ) ),
		Button Box( "Open a file",
			path = Pick File(
				"Select Raw Waveform data",
				"", // no default directory
				{"JMP Files|jmp;jsl;jrn", "All Files|*"},
				1,
				0,
				"" // no default file
			);
			dt = Open( path ); //probably should do this instead of current data table()
			//dt = Current Data Table();
			domorestuff();
		),
		Spacer Box( size( 10, 1 ) ), 

		Button Box( "Select from a list",
			choose_data_table = Function( {},
				list = {};
				For( i = 1, i &amp;lt;= N Table(), i++,
					list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
				);

				win = New Window( "Select a data table",
					&amp;lt;&amp;lt;Modal,
					hb = H List Box(
						Panel Box( "Choose a data table",
							dt = List Box(
								list,
								max selected( 1 ),
								chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] );
								Show( chosen );
							)
						),

					)
				);
				chosen;
			);
			dt = choose_data_table();
			domorestuff();
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 May 2018 18:25:26 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2018-05-22T18:25:26Z</dc:date>
    <item>
      <title>Using another button instead of "Ok" - Modal windows</title>
      <link>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57885#M32189</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Just started learning scripting so please excuse the messy or redundant coding haha.&amp;nbsp; I'm trying to combine a few things I've picked up from these forums.&amp;nbsp; Basically, give the user an option of opening a file or selecting an already open file.&amp;nbsp; I've finally figured out I needed to use a Modal window to wait for the selection is made before continuing down the script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to have the code continue when the selection is made? Instead of waiting for the user to press the "Ok" button?&amp;nbsp; So for my two options:&lt;/P&gt;&lt;P&gt;1. User opens a file --&amp;gt; continue when the file is opened&lt;/P&gt;&lt;P&gt;2. User selects an open file --&amp;gt; continue when the file is selected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, having them press the "ok" button after the selection seems redundant.&amp;nbsp; Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;InputWindow = New Window( "Pick a file opening option (must be truncated)", &amp;lt;&amp;lt;modal, 

V List Box(
   Text Box( "Pick a Cut and Truncated Waveform" ), 
  Spacer Box( size( 1, 10 ) ), 
   Button Box( "Open a file",
    path = Pick File(
	"Select Raw Waveform data",
	"", // no default directory
	{"JMP Files|jmp;jsl;jrn", "All Files|*"},
	1,
	0,
	"" // no default file
		);
	open(path);
    	dt=current data table();   
   ),
   Spacer Box( size( 10, 1 ) ), 

   Button Box( "Select from a list",
   choose_data_table=function({},
list = {};
For( i = 1, i &amp;lt;= N Table(), i++,
	list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
);

win = New Window( "Select a data table", &amp;lt;&amp;lt; Modal,
	hb = H List Box(
		Panel Box( "Choose a data table",
			dt = List Box(
				list,
				max selected( 1 ),
				chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] );
				show (chosen);
			)),)
);
chosen);
dt=choose_data_table(); 
    	    )
  )
  ) 
);
    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 18:04:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57885#M32189</guid>
      <dc:creator>DL723</dc:creator>
      <dc:date>2018-05-22T18:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using another button instead of "Ok" - Modal windows</title>
      <link>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57886#M32190</link>
      <description>&lt;P&gt;You could just manually make the okay button and click it with btn &amp;lt;&amp;lt; Click.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;InputWindow = New Window( "Pick a file opening option (must be truncated)",
	&amp;lt;&amp;lt;modal, 
	
	V List Box(
		Text Box( "Pick a Cut and Truncated Waveform" ),
		Spacer Box( size( 1, 10 ) ),
		Button Box( "Open a file",
			path = Pick File(
				"Select Raw Waveform data",
				"", // no default directory
				{"JMP Files|jmp;jsl;jrn", "All Files|*"},
				1,
				0,
				"" // no default file
			);
			dt = Open( path ); //probably should do this instead of current data table()
			//dt = Current Data Table();
			btn_ok &amp;lt;&amp;lt; Click;
		),
		Spacer Box( size( 10, 1 ) ), 

		Button Box( "Select from a list",
			choose_data_table = Function( {},
				list = {};
				For( i = 1, i &amp;lt;= N Table(), i++,
					list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
				);

				win = New Window( "Select a data table",
					&amp;lt;&amp;lt;Modal,
					hb = H List Box(
						Panel Box( "Choose a data table",
							dt = List Box(
								list,
								max selected( 1 ),
								chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] );
								Show( chosen );
							)
						),

					)
				);
				chosen;
			);
			dt = choose_data_table();
			btn_ok &amp;lt;&amp;lt; Click;
		), 
		btn_ok = Buttonbox("OK")
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it sounds like you might not need a modal dialog.&amp;nbsp; You could just have the rest of your code execution be a function or expression and send that to each button.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;domorestuff = function({}, 
	print(dt);
);
InputWindow = New Window( "Pick a file opening option (must be truncated)",
	
	V List Box(
		Text Box( "Pick a Cut and Truncated Waveform" ),
		Spacer Box( size( 1, 10 ) ),
		Button Box( "Open a file",
			path = Pick File(
				"Select Raw Waveform data",
				"", // no default directory
				{"JMP Files|jmp;jsl;jrn", "All Files|*"},
				1,
				0,
				"" // no default file
			);
			dt = Open( path ); //probably should do this instead of current data table()
			//dt = Current Data Table();
			domorestuff();
		),
		Spacer Box( size( 10, 1 ) ), 

		Button Box( "Select from a list",
			choose_data_table = Function( {},
				list = {};
				For( i = 1, i &amp;lt;= N Table(), i++,
					list[i] = Data Table( i ) &amp;lt;&amp;lt; get name
				);

				win = New Window( "Select a data table",
					&amp;lt;&amp;lt;Modal,
					hb = H List Box(
						Panel Box( "Choose a data table",
							dt = List Box(
								list,
								max selected( 1 ),
								chosen = Data Table( (dt &amp;lt;&amp;lt; get selected)[1] );
								Show( chosen );
							)
						),

					)
				);
				chosen;
			);
			dt = choose_data_table();
			domorestuff();
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 May 2018 18:25:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57886#M32190</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2018-05-22T18:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using another button instead of "Ok" - Modal windows</title>
      <link>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57889#M32193</link>
      <description>&lt;P&gt;Modal windows are designed to force a user to click OK before execution continues.&amp;nbsp; Alternatively, you can have a non-modal window and put attach a script to either a button or a display box that allows selections.&amp;nbsp; In the example below, execution continues immediately a selection is made:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
lst = {"Item 1","Item 2","Item 3","Item 4"};
nw = New Window("Selection",
	Border Box(top(20),bottom(20),left(20),right(20),
		V List Box(
			Text Box("Select an item from the list:"),
			lb = List Box(lst,&amp;lt;&amp;lt;SetMaxSelected(1),&amp;lt;&amp;lt;SetScript(doSelect()))
		)
	)
);

doSelect = Function({},{Default Local},
	lstSelected = lb &amp;lt;&amp;lt; Get Selected;
	selected = lstSelected[1];
	nw &amp;lt;&amp;lt; Close Window;
	show(selected);
	// continue your code here
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 19:25:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57889#M32193</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2018-05-22T19:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using another button instead of "Ok" - Modal windows</title>
      <link>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57897#M32196</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thanks for the replies.&amp;nbsp; Ah, I think everybody is correct in I didn't need it to be modal.&amp;nbsp; That was the first solution I found to&amp;nbsp;getting my table to stay defined after the selection was made and the script moved past the window selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either way, the self click worked for what I had written, already.&amp;nbsp; But I'll try the straight forward way of using functions.&amp;nbsp; Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2018 20:04:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-another-button-instead-of-quot-Ok-quot-Modal-windows/m-p/57897#M32196</guid>
      <dc:creator>DL723</dc:creator>
      <dc:date>2018-05-22T20:04:30Z</dc:date>
    </item>
  </channel>
</rss>

