Answered
[script ui]how to remove item from group
I have a group, and add some statictext control, but how to removeall, because i want to dynamic generate it, make it behave like listbox.
listitem cant onclick and cant custom draw(like changecolor)
I have a group, and add some statictext control, but how to removeall, because i want to dynamic generate it, make it behave like listbox.
listitem cant onclick and cant custom draw(like changecolor)
You need to update the panel using:
palette.layout.layout(true);
var palette = new Window("palette", "yuelili", undefined, { resizeable: true});
palette.orientation = "column";
var group1 = palette.add("group", undefined);
group1.orientation = "row";
group1.preferredSize.height = 0;
var group2 = palette.add("group", undefined);
group2.orientation = "column";
var addButton = group1.add("button", undefined, "add");
addButton.preferredSize.width = 95;
var removeButton = group1.add("button", undefined, "remove all");
removeButton.preferredSize.width = 95;
if (palette instanceof Window) {
palette.center();
palette.show();
} else {
palette.layout.layout(true);
palette.layout.resize();
}
addButton.onClick = function() {
var staticText = group2.add("statictext", undefined, undefined);
staticText.text = "statictext " + group2.children.length;
staticText.preferredSize.width = 200;
palette.layout.layout(true)
}
removeButton.onClick = function() {
while (group2.children.length) {
group2.remove(group2.children[0]);
}
group2.preferredSize.height = 0;
palette.layout.layout(true)
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.