Skip to main content

LensStudio:Workspaces.Metadata

Class

Display name and icon of a workspace or workspace preset.

Index

Properties

Example

Create a menu action labeled with a preset folder's name and icon. The metadata of a descriptor read from a folder takes its name from the folder and its icon from Icon.svg. Connect the action's onTrigger to IWorkspaceManager.register().

import { Action, Widget } from 'LensStudio:Ui';
import { IWorkspaceManager } from 'LensStudio:Workspaces';

export function createInstallPresetAction(
manager: IWorkspaceManager,
parent: Widget,
presetFolder: Editor.Path,
): Action | undefined {
const descriptor = manager.readDescriptor(presetFolder);
if (!descriptor) return undefined;

const { name, icon } = descriptor.metadata;
const action = new Action(parent);
action.text = `Install ${name} workspace`;
action.icon = icon;
// An installed preset cannot be registered again.
action.enabled = !manager.isRegistered(descriptor);
return action;
}

Constructors

Constructor

new Metadata(): Metadata

Constructs empty workspace metadata.

Returns

Metadata

Properties

icon

icon: Icon

Icon shown for the workspace.


name

name: string

Display name of the workspace, shown on its tab. Lens Studio keeps the names of open workspaces unique.