@jthi Thanks. This should do the job. Buttons in place of check box is fine. I have changed your script to a function but struggling to place get selected () correctly to get the selected values as list (e.g. my commented Return statement at the bottom of the function) when user clicks OK. Please could I get some pointers on where to place get selected () correctly?
Names Default To Here (1);
getUserInput = Function ({aa_parent}, {return_selectionAslist},
aa_parents << Set Default Value({});
get_childids = function({this}, {Default Local},
new_childids = aa_parents[(this << prev sib) << get text];
lb_child << Set items(new_childids);
);
nw = New Window("",
H List Box(
Panel Box("[1] Enter Parent ID",
Lineup Box(N Col(2),
Text Edit Box("", << Set Width(150)),
Button Box("Get Child Ids", << set function(function({this},
get_childids(this);
)))
)
),
Panel Box("[2] Select Child ID",
H List Box(
lb_child = List Box({}),
Lineup Box(N Col(1),
Button Box("Select All",
For Each({item, idx}, lb_child << get items,
lb_child << Set Selected(idx);
);
wait(0);
),
Button Box("Unselect All",
lb_child << Clear selection;
),
)
)
),
Panel Box("[3] Fetch Test Data",
Lineup Box(N Col(1),
Button Box("OK"),
Button Box("Cancel")
)
)
)
);
// return_selectionAslist = As List [Parent ID, selected_Child_ID(s) ];
Return (return_selectionAslist);
);
//Test
clear log ();
aa_parent_1 = ["123" => {"111", "222", "333"}]; aa_parent_2 = ["345" => {"555", "777", "999"}];
myList= getUserInput (aa_parent_1);
When it's too good to be true, it's neither