LensStudio:DialogPlugin.DialogPlugin
ClassBase class for dialog plugins; extend to implement custom dialogs with a createWidget method.
Index
Properties
Methods
Example
// DialogPlugin is the base class for all dialog-based plugins.
// It extends Editor.IPlugin with show() and deinit() lifecycle methods.
//
// Lifecycle:
// 1. User triggers menu action (from menuActionHierarchy)
// 2. show(parent) is called — build and return the Dialog
// 3. User interacts with the dialog
// 4. Dialog closes — deinit() is called for cleanup
export class DialogPluginDialogPluginExampleDialog extends DialogPlugin {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.DialogPluginDialogPluginExample';
d.name = 'DialogPlugin Class Example';
d.description = 'Demonstrates the DialogPlugin class lifecycle';
d.dependencies = [Editor.Model.IModel];
d.menuActionHierarchy = ['Window', 'Examples', 'DialogPlugin Class'];
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
show(parent: Widget): Dialog {
const dialog = new Dialog(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
dialog.layout = layout;
const info = new Label(dialog);
info.wordWrap = true;
layout.addWidget(info);
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as unknown as Editor.Model.IModel;
const count = model.project.scene.rootSceneObjects.length;
info.text = `Project has ${count} root scene object(s).`;
const closeBtn = new PushButton(dialog);
closeBtn.text = 'Done';
this.connections.push(closeBtn.onClick.connect(() => dialog.accept()));
layout.addWidget(closeBtn);
return dialog;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
}
}
Extends
Constructors
Constructor
new DialogPlugin(
pluginSystem,descriptor?):DialogPlugin
Constructs a new DialogPlugin instance with the given plugin system and optional descriptor.
Parameters
| Parameter | Type |
|---|---|
pluginSystem | PluginSystem |
descriptor? | Descriptor |
Returns
DialogPlugin
Overrides
Editor.IPlugin.constructor
Properties
id
readonlyid:string
Unique string identifier of the plugin instance.
Inherited from
pluginSystem
readonlypluginSystem:PluginSystem
The PluginSystem instance that owns and manages this plugin.
Methods
deinit()
deinit():
void
Tears down the plugin and releases its resources.
Returns
void
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
show()
show(
parent):Dialog
Creates and displays the dialog as a child of the given parent widget, returning the resulting Dialog instance.
Parameters
| Parameter | Type |
|---|---|
parent | Widget |