Mwni / pixi-text-input

Plugin for pixi.js which provides a convenient way of adding a text input to the pixijs-stage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Restrict and backspace

oldenboom opened this issue · comments

With TextInput I can:

  • backspace any character
  • select all with cmd-a (ctrl-A on windows) and then hitting backspace erases everything entered

Then I set restrict to '[a-zA-Z0-9\ ]+'. This causes:

  • backspace works but for the first entered character. I cannot remove that one with backspace. I just have to select everything and start typing
  • select all and then hitting backspace doesn't do anything. Select all and then typing does work though but is less intuitive.

I tried adding \b to the regexp but this doesn't solve the issue. Something prevents backspace to work properly when using the restrict option.

commented

The regex is applied over the whole text, not on a character basis.
So in your case you'd have to write [a-zA-Z0-9\ ]* instead of [a-zA-Z0-9\ ]+. The + quantifier does not allow for an empty string.

That sure makes sense. Tried it and it did fix the issues. Thanks!