Using another button instead of "Ok" - Modal windowsHi,
Just started learning scripting so please excuse the messy or redundant coding haha. I'm trying to combine a few things I've picked up from these forums. Basically, give the user an option of opening a file or selecting an already open file. I've finally figured out I needed to use a Modal window to wait for the selection is made before continuing down the script.
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? So for my two options:
1. User opens a file --> continue when the file is opened
2. User selects an open file --> continue when the file is selected
Right now, having them press the "ok" button after the selection seems redundant. Thanks for any help!
InputWindow = New Window( "Pick a file opening option (must be truncated)", <<MODAL></MODAL>
Re: Using another button instead of "Ok" - Modal windowsHi,
Thanks for the replies. Ah, I think everybody is correct in I didn't need it to be modal. That was the first solution I found to getting my table to stay defined after the selection was made and the script moved past the window selection.
Either way, the self click worked for what I had written, already. But I'll try the straight forward way of using functions. Thanks again.
Re: Using another button instead of "Ok" - Modal windowsModal windows are designed to force a user to click OK before execution continues. Alternatively, you can have a non-modal window and put attach a script to either a button or a display box that allows selections. In the example below, execution continues immediately a selection is made:
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,<<SETMAXSELECTED></SETMAXSELECTED>
Re: Using another button instead of "Ok" - Modal windowsYou could just manually make the okay button and click it with btn << Click.
InputWindow = New Window( "Pick a file opening option (must be truncated)",
<<MODAL></MODAL>
But it sounds like you might not need a modal dialog. You could just have the rest of your code execution be a function or expression and send that to each button.
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 <= N Table(), i++,
list[i] = Data Table( i ) << get name
);
win = New Window( "Select a data table",
<<MODAL></MODAL>