Repository navigation
Expand file tree
/
Copy pathtextentryruntimeobject.ts
More file actions
67 lines (58 loc) · 1.68 KB
/
Copy pathtextentryruntimeobject.ts
File metadata and controls
67 lines (58 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* GDevelop JS Platform
* 2013 Florian Rival (Florian.Rival@gmail.com)
*/
namespace gdjs {
/**
* The TextEntryRuntimeObject allows to capture text typed on the keyboard.
*/
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
) {
super(instanceContainer, textEntryObjectData);
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
);
}