mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-21 09:35:27 -04:00
deb802cfec
* For now, this is limited to instances inside custom objects. This will be made available in the future for all instances in scenes if this works well.
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
/*
|
|
* GDevelop JS Platform
|
|
* 2013 Florian Rival (Florian.Rival@gmail.com)
|
|
*/
|
|
namespace gdjs {
|
|
/**
|
|
* The TextEntryRuntimeObject allows to capture text typed on the keyboard.
|
|
* @category Objects > Text Entry
|
|
* @deprecated
|
|
*/
|
|
export class TextEntryRuntimeObject extends gdjs.RuntimeObject {
|
|
_str: string = '';
|
|
_activated: boolean = true;
|
|
_renderer: gdjs.TextEntryRuntimeObjectRenderer;
|
|
|
|
/**
|
|
* @param instanceContainer The container the object belongs to.
|
|
* @param textEntryObjectData The initial properties of the object
|
|
*/
|
|
constructor(
|
|
instanceContainer: gdjs.RuntimeInstanceContainer,
|
|
textEntryObjectData: ObjectData,
|
|
instanceData?: InstanceData
|
|
) {
|
|
super(instanceContainer, textEntryObjectData, instanceData);
|
|
this._renderer = new gdjs.TextEntryRuntimeObjectRenderer(this);
|
|
|
|
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
|
|
this.onCreated();
|
|
}
|
|
|
|
updateFromObjectData(oldObjectData, newObjectData): boolean {
|
|
// Nothing to update.
|
|
return true;
|
|
}
|
|
|
|
onDestroyed(): void {
|
|
super.onDestroyed();
|
|
this._renderer.onDestroy();
|
|
}
|
|
|
|
update(instanceContainer: gdjs.RuntimeInstanceContainer): void {
|
|
if ((this._renderer as any).getString) {
|
|
this._str = (this._renderer as any).getString();
|
|
}
|
|
}
|
|
|
|
getString(): string {
|
|
return this._str;
|
|
}
|
|
|
|
setString(str: string): void {
|
|
this._str = str;
|
|
this._renderer.updateString();
|
|
}
|
|
|
|
isActivated(): boolean {
|
|
return this._activated;
|
|
}
|
|
|
|
activate(enable: boolean) {
|
|
this._activated = enable;
|
|
this._renderer.activate(this._activated);
|
|
}
|
|
}
|
|
gdjs.registerObject(
|
|
'TextEntryObject::TextEntry',
|
|
gdjs.TextEntryRuntimeObject
|
|
);
|
|
}
|