Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Phaser.Text can't be empty string


InsaneHero
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...