input-mask-android icon indicating copy to clipboard operation
input-mask-android copied to clipboard

Non-removable prefix

Open milk-machine opened this issue 7 years ago • 5 comments

In some cases I need non-removable prefix. Add this feature, please :)

milk-machine avatar Oct 19 '18 11:10 milk-machine

@milk-machine, how do you want to see a mask and a result of removing symbols?

CoolMind avatar Oct 25 '18 13:10 CoolMind

Hey @milk-machine! Thanks for your suggestion.

I'll keep this feature request, though I can't say this feature will come out soon. It's a little bit controversial, plus the implementation raises lots of design questions, including the one above by @CoolMind

taflanidi avatar Oct 30 '18 18:10 taflanidi

yes this is very needed, ThnQ

TurKurT656 avatar Jul 18 '19 07:07 TurKurT656

Hi, @taflanidi is there any update?

P.S. As there is no official solution I would like to introduce a shortcut. Just override afterTextChanged method in MaskedTextChangedListener:

override fun afterTextChanged(edit: Editable?) {
    val text = field.text.toString()
    if (!text.startsWith(nonRemovePrefix)) {
        setText(nonRemovePrefix, field)
    } else {
        super.afterTextChanged(edit)
    }
}

https://gist.github.com/dmersiyanov/2b8f6f9472969fc0dd23749ec8f5c8f0

dmersiyanov avatar Jul 24 '20 14:07 dmersiyanov

I'll look into pulling this into the core, thank you so much!

taflanidi avatar Apr 11 '23 07:04 taflanidi