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

[script ui]how to remove item from group

Community Beginner ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

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

Views

113

Translate

Translate

Report

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

Engaged , 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
...

Votes

Translate

Translate
Community Beginner ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

I try

for i ... group.children.length

group.remove(...[i]) 

delete ...

 

but not work

Votes

Translate

Translate

Report

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
Engaged ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

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

 

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

LATEST

ohhhh it works well now! verrrry thanks!

Votes

Translate

Translate

Report

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