InsaneHero Posted September 18, 2014 Share Posted September 18, 2014 My edit box is working perfectly apart from one detail.When I try to delete existing text and enter a new string, it cannot delete the first character. After some poking around I found it is due to this code:PIXI.Text.prototype.setText = function(text){ this.text = text.toString() || ' '; this.dirty = true;};So when I delete the last character in a string then try to assign the now empty string to the Text.text field, it is being replaced with a space. Is there a reason why I shouldn't fix this by using '' instead of ' '? Empty strings are normally quite acceptable, but perhaps there's something deeper inside which I haven't spotted yet. EDIT: just noticed this is PIXI, not Phaser... I'll go ask them Link to comment Share on other sites More sharing options...
InsaneHero Posted September 18, 2014 Author Share Posted September 18, 2014 Bah, ever had one of those days? Turns out it is in Phaser too:/*** The text string to be displayed by this Text object, taking into account the style settings.* @name Phaser.Text#text* @property {string} text - The text string to be displayed by this Text object, taking into account the style settings.*/Object.defineProperty(Phaser.Text.prototype, 'text', { get: function() { return this._text; }, set: function(value) { if (value !== this._text) { this._text = value.toString() || ' '; this.dirty = true; this.updateTransform(); } }});I've changed both instances (PIXI and Phaser) to use '' and it seems to be working fine. Link to comment Share on other sites More sharing options...
rich Posted September 18, 2014 Share Posted September 18, 2014 Yeah it used to crash Pixi with an empty string, so they defaulted to a blank space and I of course had to copy that in Phaser. If it's now working properly in Pixi then I can update it in Phaser too. Link to comment Share on other sites More sharing options...
InsaneHero Posted September 18, 2014 Author Share Posted September 18, 2014 I'll get back to you if the guys over in the PIXI forum tell me it's safe. Link to comment Share on other sites More sharing options...
Recommended Posts