Skip to main content

LensStudio:DialogPlugin.DialogPlugin

Class

Base class for dialog plugins; extend to implement custom dialogs with a createWidget method.

Index

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

ParameterType
pluginSystemPluginSystem
descriptor?Descriptor

Returns

DialogPlugin

Overrides

Editor.IPlugin.constructor

Properties

id

readonly id: string

Unique string identifier of the plugin instance.

Inherited from

IPlugin.id


pluginSystem

readonly pluginSystem: 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()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

IPlugin.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

IPlugin.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

IPlugin.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

IPlugin.isSame


show()

show(parent): Dialog

Creates and displays the dialog as a child of the given parent widget, returning the resulting Dialog instance.

Parameters

ParameterType
parentWidget

Returns

Dialog