Copy link to clipboard
Copied
I'm trying to create a dialogue box to collect data for a graph. I need to be able to add extra data fields depending on how many graph lines are needed. The script I have so far allows me to add or subtract data fields but when I add a field the next field will not allow text to be added to it unless I then add another field after it. I have found a hack by adding an empty dummy group along with the text field I want to add which does work but it seems like a very poor way of going about things. Can someone please help?
var win = new Window ("dialog");
var maingroup = win.add ("panel {orientation: 'column'}");
add_row (maingroup);
//add_DummyGroup (maingroup)
var show_btn = win.add ("button", undefined, "show");
show_btn.onClick = function () {
var txt = " ";
for (var n = 0; n < maingroup.children.length; n++) {
txt += maingroup.children[n].edit.text + "\n";
}
alert ("Rows: \n" + txt);
}
win.show ();
function add_row (maingroup) {
var group = maingroup.add ("group");
// group.edit = group.add ("edittext", [" ", " ", 200, 20], maingroup.children.length);
group.edit = group.add ("edittext", [0, 0, 70, 150], "Dummy Text", {multiline: true, scrolling: true});
group.plus = group.add ("button", undefined, "+");
group.plus.onClick = add_btn;
group.minus = group.add ("button", undefined, "-");
group.minus.onClick = minus_btn;
group.index = maingroup.children.length - 1;
win.layout.layout (true);
}
function add_DummyGroup (maingroup) {
var group2 = maingroup.add ("group");
win.layout.layout (true);
}
function add_btn () {
add_row (maingroup);
add_DummyGroup (maingroup)
}
function minus_btn () {
maingroup.remove (this.parent);
win.layout.layout (true);
}
Copy link to clipboard
Copied
If you're inputting so much data that you need multiple multiline textboxes, couldn't you just choose a delimiter like a line break?
I noticed the main code is from the scriptUI guide, and tested a little with your code and the scriptUI builder. I don't think your workaround is bad, although the show button doesn't seem to work(looks like you have to remove the dummy groups also). What I noticed is that the scrollbars and the height of the edittext boxes seem to be having the issue, as if they're getting closed early by some tag. If you set the edittext height up to 60 they seem to work fine without the dummy group.