Skip to main content

LensStudio:ModelUi.EntityReferencePickerLine

Class

Line edit widget for picking entity references by type, backed by an asset manager and entity prototype registry.

Index

Example

// EntityReferencePickerLine is a LineEdit widget for picking scene entities.
// Construct it with an AssetManager, IEntityPrototypeRegistry, entity type, and parent.
const root = new Widget(parent);
const layout = new BoxLayout();
layout.setDirection(Direction.TopToBottom);
layout.spacing = 8;
root.layout = layout;

const title = new Label(root);
title.text = 'Entity Reference Picker';
layout.addWidget(title);

const model = this.pluginSystem.findInterface(
Editor.Model.IModel.interfaceId
) as Editor.Model.IModel;
const registry = this.pluginSystem.findInterface(
Editor.Model.IEntityPrototypeRegistry.interfaceId
) as Editor.Model.IEntityPrototypeRegistry;

if (Editor.isNull(model) || Editor.isNull(registry)) {
const err = new Label(root);
err.text = 'Required interfaces not available';
layout.addWidget(err);
return root;
}

const assetManager = model.project.assetManager;
const picker = new EntityReferencePickerLine(assetManager, registry, 'SceneObject', root);
layout.addWidget(picker);

const status = new Label(root);
status.text = 'Pick a SceneObject above';
layout.addWidget(status);

this.connections.push(
picker.onEntityChoose.connect(() => {
status.text = 'Entity chosen';
})
);
this.connections.push(
picker.onEntityClear.connect(() => {
status.text = 'Entity cleared';
})
);
this.connections.push(
picker.onEntityDrop.connect((entity: Editor.Model.Entity) => {
status.text = 'Entity dropped';
})
);

Extends

Constructors

Constructor

new EntityReferencePickerLine(assetManager, entityPrototypeRegistry, entityType, parent): EntityReferencePickerLine

Constructs an EntityReferencePickerLine widget for picking entity references of a given type, bound to the specified asset manager and entity prototype registry.

Parameters

ParameterType
assetManagerAssetManager
entityPrototypeRegistryIEntityPrototypeRegistry
entityTypestring
parentWidget

Returns

EntityReferencePickerLine

Overrides

LineEdit.constructor

Properties

autoFillBackground

autoFillBackground: boolean

Whether the widget automatically fills its background before painting.

Inherited from

LineEdit.autoFillBackground


backgroundRole

backgroundRole: ColorRole

The color role used for the widget's background.

Inherited from

LineEdit.backgroundRole


className

readonly className: string

Class name of the underlying widget type.

Inherited from

LineEdit.className


contextMenuPolicy

contextMenuPolicy: ContextMenuPolicy

Controls how the widget handles context menu requests.

Inherited from

LineEdit.contextMenuPolicy


cursorPosition

cursorPosition: number

The current position of the text cursor.

Inherited from

LineEdit.cursorPosition


devicePixelRatio

readonly devicePixelRatio: number

The ratio between physical and logical pixels for the widget's display.

Inherited from

LineEdit.devicePixelRatio


enabled

enabled: boolean

Whether the widget is interactive and accepts user input.

Inherited from

LineEdit.enabled


fontRole

fontRole: FontRole

The font role applied to the widget's text rendering.

Inherited from

LineEdit.fontRole


foregroundRole

foregroundRole: ColorRole

The color role used for the widget's foreground elements.

Inherited from

LineEdit.foregroundRole


hasFocus

readonly hasFocus: boolean

True when the widget currently holds keyboard focus.

Inherited from

LineEdit.hasFocus


height

readonly height: number

Current height of the widget in pixels.

Inherited from

LineEdit.height


hidden

hidden: boolean

Whether the widget is hidden from view.

Inherited from

LineEdit.hidden


icon

icon: Icon

The icon displayed in the line edit.

Inherited from

LineEdit.icon


isNull

readonly isNull: boolean

True if the underlying native widget object has been destroyed.

Inherited from

LineEdit.isNull


isTransparentForMouseEvents

isTransparentForMouseEvents: boolean

When true, mouse events pass through the widget to widgets below.

Inherited from

LineEdit.isTransparentForMouseEvents


layout

layout: Layout

The layout manager assigned to arrange child widgets.

Inherited from

LineEdit.layout


objectName

objectName: string

Identifier by which the widget can be located via findChild.

Inherited from

LineEdit.objectName


onAssetHighlight

readonly onAssetHighlight: signal0<void>

Fired when an asset is highlighted in the picker.


onClose

readonly onClose: signal1<CloseEvent, void>

Signal emitted when the widget is closed.

Inherited from

AbstractButton.onClose


onEditingFinished

readonly onEditingFinished: signal0<void>

Signal emitted when editing is finished.

Inherited from

LineEdit.onEditingFinished


onEntityChoose

readonly onEntityChoose: signal0<void>

Fired when the user confirms an entity selection.


onEntityClear

readonly onEntityClear: signal0<void>

Fired when the current entity reference is cleared.


onEntityDrop

readonly onEntityDrop: signal1<Entity, void>

Fired when an entity is dropped onto the picker, carrying the dropped entity.


onEntitySelect

readonly onEntitySelect: signal0<void>

Fired when an entity is selected in the picker.


onFocusIn

readonly onFocusIn: signal0<void>

Emitted when the widget gains keyboard focus.

Inherited from

LineEdit.onFocusIn


onFocusOut

readonly onFocusOut: signal0<void>

Emitted when the widget loses keyboard focus.

Inherited from

LineEdit.onFocusOut


onHide

readonly onHide: signal0<void>

Signal emitted when the widget becomes hidden.

Inherited from

LineEdit.onHide


onKeyPress

readonly onKeyPress: signal1<number, void>

Signal emitted when a key is pressed while the widget has focus.

Inherited from

LineEdit.onKeyPress


onMouseDoubleClick

readonly onMouseDoubleClick: signal1<MouseEvent, void>

Signal emitted when the user double-clicks on the widget.

Inherited from

AbstractButton.onMouseDoubleClick


onMouseMove

readonly onMouseMove: signal1<MouseEvent, void>

Signal emitted when the mouse moves over the widget.

Inherited from

AbstractButton.onMouseMove


onMousePress

readonly onMousePress: signal1<MouseEvent, void>

Signal emitted when a mouse button is pressed on the widget.

Inherited from

AbstractButton.onMousePress


onMouseRelease

readonly onMouseRelease: signal1<MouseEvent, void>

Signal emitted when a mouse button is released on the widget.

Inherited from

AbstractButton.onMouseRelease


onResize

readonly onResize: signal2<number, number, void>

Signal emitted when the widget is resized.

Inherited from

LineEdit.onResize


onReturnPressed

readonly onReturnPressed: signal0<void>

Signal emitted when the return key is pressed.

Inherited from

LineEdit.onReturnPressed


onShow

readonly onShow: signal0<void>

Signal emitted when the widget becomes visible.

Inherited from

LineEdit.onShow


onTextChange

readonly onTextChange: signal1<string, void>

Signal emitted when the text changes.

Inherited from

LineEdit.onTextChange


placeholderText

placeholderText: string

Placeholder text shown when the input is empty.

Inherited from

LineEdit.placeholderText


readonly

readonly: boolean

Whether the line edit is read-only.

Inherited from

LineEdit.readonly


text

text: string

The current text content.

Inherited from

LineEdit.text


toolTip

toolTip: string

Text displayed in a tooltip when the user hovers over the widget.

Inherited from

LineEdit.toolTip


visible

visible: boolean

Whether the widget is currently visible.

Inherited from

LineEdit.visible


width

readonly width: number

Current width of the widget in pixels.

Inherited from

LineEdit.width


windowTitle

windowTitle: string

Title text displayed in the widget's title bar when shown as a window.

Inherited from

LineEdit.windowTitle

Methods

actions()

actions(): Action[]

Returns

Action[]

Inherited from

LineEdit.actions


activateWindow()

activateWindow(): void

Brings the widget's top-level window to the foreground and gives it focus.

Returns

void

Inherited from

LineEdit.activateWindow


adjustSize()

adjustSize(): void

Resizes the widget to fit its contents based on the size hint.

Returns

void

Inherited from

LineEdit.adjustSize


blockSignals()

blockSignals(blocked): void

Blocks or unblocks signal emission from the widget.

Parameters

ParameterType
blockedboolean

Returns

void

Inherited from

LineEdit.blockSignals


close()

close(): void

Closes the widget, hiding it and emitting the onClose signal.

Returns

void

Inherited from

LineEdit.close


deleteLater()

deleteLater(): void

Schedules the widget for deletion after the current event loop iteration.

Returns

void

Inherited from

LineEdit.deleteLater


findChild()

findChild(objectName): Widget

Returns the descendant widget with the given object name, or null if none matches.

Parameters

ParameterType
objectNamestring

Returns

Widget

Inherited from

LineEdit.findChild


getProperty()

getProperty(name): any

Returns the value of the dynamic property with the given name.

Parameters

ParameterType
namestring

Returns

any

Inherited from

LineEdit.getProperty


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

LineEdit.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

LineEdit.getTypeName


grab()

grab(): Pixmap

Captures the widget's current rendered content as a Pixmap.

Returns

Pixmap

Inherited from

LineEdit.grab


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

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

LineEdit.isSame


mapToGlobal()

mapToGlobal(x, y): Point

Parameters

ParameterType
xnumber
ynumber

Returns

Point

Inherited from

LineEdit.mapToGlobal


move()

move(ax, ay): void

Moves the widget to the specified position.

Parameters

ParameterType
axnumber
aynumber

Returns

void

Inherited from

LineEdit.move


raise()

raise(): void

Raises the widget to the top of the parent widget's stack.

Returns

void

Inherited from

LineEdit.raise


resize()

resize(width, height): void

Resizes the widget to the specified width and height.

Parameters

ParameterType
widthnumber
heightnumber

Returns

void

Inherited from

LineEdit.resize


setContentsMargins()

setContentsMargins(left, top, right, bottom): void

Sets the margins around the widget's contents.

Parameters

ParameterType
leftnumber
topnumber
rightnumber
bottomnumber

Returns

void

Inherited from

LineEdit.setContentsMargins


setCursor()

setCursor(shape): void

Sets the cursor shape displayed when the mouse is over the widget.

Parameters

ParameterType
shapeCursorShape

Returns

void

Inherited from

LineEdit.setCursor


setCursorPixmap()

setCursorPixmap(pixmap): void

Sets a custom pixmap as the cursor when the mouse is over the widget.

Parameters

ParameterType
pixmapPixmap

Returns

void

Inherited from

LineEdit.setCursorPixmap


setFixedHeight()

setFixedHeight(height): void

Locks the widget's height to the given value, preventing resizing.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

LineEdit.setFixedHeight


setFixedWidth()

setFixedWidth(width): void

Locks the widget's width to the given value, preventing resizing.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

LineEdit.setFixedWidth


setFocus()

setFocus(): void

Gives keyboard input focus to the widget.

Returns

void

Inherited from

LineEdit.setFocus


setMaximumHeight()

setMaximumHeight(height): void

Sets the maximum height the widget can be resized to.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

LineEdit.setMaximumHeight


setMaximumWidth()

setMaximumWidth(width): void

Sets the maximum width the widget can be resized to.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

LineEdit.setMaximumWidth


setMinimumHeight()

setMinimumHeight(height): void

Sets the minimum height the widget must maintain.

Parameters

ParameterType
heightnumber

Returns

void

Inherited from

LineEdit.setMinimumHeight


setMinimumWidth()

setMinimumWidth(width): void

Sets the minimum width the widget must maintain.

Parameters

ParameterType
widthnumber

Returns

void

Inherited from

LineEdit.setMinimumWidth


setProperty()

setProperty(name, value): boolean

Sets the dynamic property with the given name to the given value.

Parameters

ParameterType
namestring
valueany

Returns

boolean

Inherited from

LineEdit.setProperty


setSizePolicy()

setSizePolicy(horizontal, vertical): void

Controls how the widget grows or shrinks relative to its layout.

Parameters

ParameterType
horizontalPolicy
verticalPolicy

Returns

void

Inherited from

LineEdit.setSizePolicy


setUndoable()

setUndoable(undoable): void

Marks property changes on this widget as undoable via the undo stack.

Parameters

ParameterType
undoableboolean

Returns

void

Inherited from

LineEdit.setUndoable


setUndoableRecursive()

setUndoableRecursive(undoable): void

Marks property changes on this widget and all its children as undoable.

Parameters

ParameterType
undoableboolean

Returns

void

Inherited from

LineEdit.setUndoableRecursive


show()

show(): void

Makes the widget visible.

Returns

void

Inherited from

LineEdit.show


unsetCursor()

unsetCursor(): void

Resets the cursor to the parent widget's cursor.

Returns

void

Inherited from

LineEdit.unsetCursor