Skip to main content

LensStudio:Ui.Shortcut

Class

Keyboard shortcut bound to a widget that emits a signal when its key sequence is activated.

Index

Example

const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
root.layout = layout;

const status = new Label(root);
status.text = 'Press Ctrl+Shift+R';
layout.addWidgetWithStretch(status, 0, 0);

const shortcut = new Shortcut(root, 'Ctrl+Shift+R', ShortcutContext.WidgetShortcut);
this.connections.push(
shortcut.onActivated.connect(() => {
status.text = 'Ctrl+Shift+R activated';
}),
);

Extends

Constructors

Constructor

new Shortcut(parent, keySequence, context): Shortcut

Constructs a shortcut on the parent widget for the given key sequence and activation context.

Parameters

ParameterType
parentWidget
keySequencestring
contextShortcutContext

Returns

Shortcut

Overrides

ScriptObject.constructor

Properties

onActivated

readonly onActivated: signal0<void>

Emitted when the shortcut's key sequence is pressed.


onActivatedAmbiguously

readonly onActivatedAmbiguously: signal0<void>

Emitted when the key sequence matches multiple shortcuts and the target is ambiguous.

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