Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[script ui]how to remove item from group

Explorer ,
Jan 24, 2024 Jan 24, 2024

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)

TOPICS
Scripting
586
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jan 24, 2024 Jan 24, 2024

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("butto
...
Translate
Explorer ,
Jan 24, 2024 Jan 24, 2024

I try

for i ... group.children.length

group.remove(...[i]) 

delete ...

 

but not work

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 24, 2024 Jan 24, 2024

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)
}

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2024 Jan 24, 2024
LATEST

ohhhh it works well now! verrrry thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines