Skip to main content

Editor.IContext

Class

Editor context passed to context action callbacks when a right-click menu is triggered.

Index

Example

// IContext is the abstract base passed to every context-menu action callback.
// Concrete subclasses: AssetContext (right-click in asset browser)
// and ObjectContext (right-click a scene object). Use isOfType()
// to branch on the actual context at call time.
const registry = this.pluginSystem.findInterface(
Editor.IContextActionRegistry.interfaceId
) as Editor.IContextActionRegistry;

const guard = registry.registerAction((ctx: Editor.IContext) => {
if (ctx.isOfType('Editor.Model.AssetContext')) {
const assetCtx = ctx as Editor.Model.AssetContext;
console.log(`AssetContext: ${assetCtx.selection.length} asset(s) selected`);
} else if (ctx.isOfType('Editor.Model.ObjectContext')) {
const objCtx = ctx as Editor.Model.ObjectContext;
console.log(`ObjectContext: ${objCtx.selection.length} object(s) selected`);
}
return undefined as unknown as Editor;
});
this.guards.push(guard);

Extends

Extended by

Methods

getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.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

ScriptObject.isSame