Files
GDevelop/Extensions/TextEntryObject/textentryruntimeobject.js
T
Lizard-13 525ea4b042 Fix Text Entry crash on HTML5
As the text entry object has no real renderable object, PIXI (only tested this renderer) crash trying to set the renderable object on Z-Order and Layer updates, a better solution is welcomed :)
2017-06-17 14:37:07 -03:00

67 lines
1.8 KiB
JavaScript

/*
* GDevelop JS Platform
* 2013 Florian Rival (Florian.Rival@gmail.com)
*/
/**
* The TextEntryRuntimeObject allows to capture text typed on the keyboard.
*
* @class TextEntryRuntimeObject
* @extends RuntimeObject
* @namespace gdjs
*/
gdjs.TextEntryRuntimeObject = function(runtimeScene, objectData)
{
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
this._str = "";
this._activated = true;
if (this._renderer)
gdjs.TextEntryRuntimeObjectRenderer.call(this._renderer, this, runtimeScene);
else
this._renderer = new gdjs.TextEntryRuntimeObjectRenderer(this, runtimeScene);
};
gdjs.TextEntryRuntimeObject.prototype = Object.create( gdjs.RuntimeObject.prototype );
gdjs.TextEntryRuntimeObject.thisIsARuntimeObjectConstructor = "TextEntryObject::TextEntry";
gdjs.TextEntryRuntimeObject.prototype.onDeletedFromScene = function(runtimeScene) {
gdjs.RuntimeObject.prototype.onDeletedFromScene.call(this, runtimeScene);
if (this._renderer.ownerRemovedFromScene) {
this._renderer.ownerRemovedFromScene();
}
};
gdjs.TextEntryRuntimeObject.prototype.update = function() {
if (this._renderer.getString) {
this._str = this._renderer.getString();
}
};
gdjs.TextEntryRuntimeObject.prototype.getString = function() {
return this._str;
};
gdjs.TextEntryRuntimeObject.prototype.setString = function(str) {
this._str = str;
this._renderer.updateString();
};
gdjs.TextEntryRuntimeObject.prototype.isActivated = function() {
return this._activated;
};
gdjs.TextEntryRuntimeObject.prototype.activate = function(enable) {
this._activated = enable;
this._renderer.activate(this._activated);
};
gdjs.TextEntryRuntimeObject.prototype.setLayer = function(layer) {
// No renderable object
};
gdjs.TextEntryRuntimeObject.prototype.setZOrder = function(z) {
// No renderable object
};