LensStudio:Ui.ListWidgetItem
ClassIndividual item in a ListWidget.
Index
Example
export class ListWidgetItemPanel extends PanelPlugin {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.UiListWidgetItemExample';
d.name = 'ListWidgetItem Example';
d.defaultDockState = DockState.Detached;
d.defaultSize = new Size(350, 300);
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
createWidget(parent: Widget): Widget {
const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
root.layout = layout;
const title = new Label(root);
title.text = 'ListWidget + ListWidgetItem';
title.fontRole = FontRole.TitleBold;
layout.addWidget(title);
const list = new ListWidget(root);
layout.addWidget(list);
// Create items with text and properties
const items = ['Camera', 'Light', 'Mesh'];
for (let i = 0; i < items.length; i++) {
const item = new ListWidgetItem(list);
item.text = items[i];
item.sizeHint = new Size(200, 30);
list.addItem(item);
}
list.setCurrentRow(0);
const status = new Label(root);
status.text = 'Selected: Camera';
layout.addWidget(status);
this.connections.push(
list.onCurrentRowChanged.connect((row: number) => {
status.text = 'Selected: ' + items[row];
})
);
return root;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
}
}
Extends
Constructors
Constructor
new ListWidgetItem(
parent):ListWidgetItem
Construct a list widget item for use in ListWidget containers.
Parameters
| Parameter | Type |
|---|---|
parent | ListWidget |
Returns
ListWidgetItem
Overrides
ScriptObject.constructor
Properties
hidden
hidden:
boolean
Whether the list item is hidden from display.
selected
selected:
boolean
Whether the list item is currently selected.
sizeHint
sizeHint:
Size
Suggested dimensions for rendering the list item.
text
text:
string
The text label displayed for the list item.
Methods
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
setIcon()
setIcon(
icon):void
Sets the icon displayed for this list item.
Parameters
| Parameter | Type |
|---|---|
icon | Icon |
Returns
void