Giter VIP home page Giter VIP logo

Comments (6)

taflanidi avatar taflanidi commented on August 18, 2024 1

@caioremedio,

Awesome, worked like a charm. So instead checking if completed == true, now I should rely on value.count > MaskedTextFieldDelegate.acceptableValueLength() right?

Yep.

Oh what I mean was, instead of implementing custom notations (if takes too much work) with ellipsis, just implement blank space character.

In fact, using of custom notations here would require less work on our side.

Gotcha. In the meantime gonna use default UITextFieldDelegate for that.

Stay tuned for the Compiler updates this weekend.

from input-mask-ios.

taflanidi avatar taflanidi commented on August 18, 2024 1

@caioremedio,

Alright, now elliptical masks support custom notations, too.

Check out the newest 3.4.1.

from input-mask-ios.

taflanidi avatar taflanidi commented on August 18, 2024

Hey @caioremedio!
Thanks for your questions. I already see a potential feature request.

First, for your "[0000] [0000] [0000] [0000] [999]" credit card mask custom notations might be your answer. You need an optional space character, like this:

"[0000] [0000] [0000] [0000][s][999]"

Notation(character: "s", characterSet: CharacterSet(charactersIn: " "), isOptional: true)

—please try it out and let me know your results.

Second, I noticed a logic flaw in our Compiler. Right now, our library tries to inherit characteristics of the […] depending on the previous character, and it doesn't support custom notations for this previous character (see the link).

I'll need to update the library for your needs, okay?

from input-mask-ios.

caioremedio avatar caioremedio commented on August 18, 2024

Hi @taflanidi , thanks for quick reply.

First: I tried with [s] but it's not auto inserting blank space character. I'm missing something here?

I'm using subclass of MaskedTextFieldDelegate, I created some custom inits for customNotations:

class NotifyingMaskedTextFieldDelegate: MaskedTextFieldDelegate {

    weak var editingListener: NotifyingMaskedTextFieldDelegateListener?

    override init(format: String) {
        super.init(format: format)
    }

    convenience init(format: String, customNotations: [Notation]) {
        self.init(format: format)
        self.customNotations = customNotations
    }

    convenience init(format: String, customNotation: Notation) {
        self.init(format: format, customNotations: [customNotation])
    }
}

Initializing:

NotifyingMaskedTextFieldDelegate(
    format: "[0000] [0000] [0000] [0000][s][999]",
    customNotation: Notation(character: "s",
                             characterSet: CharacterSet(charactersIn: " "),
                             isOptional: true))

Second: Alright, but it's possible to include only blank space in the Compiler (along with Numbers and Letters)?

Thanks for the support.

from input-mask-ios.

taflanidi avatar taflanidi commented on August 18, 2024

Hey @caioremedio,

I tried with [s] but it's not auto inserting blank space character. I'm missing something here?

Oh, I forgot about that. I even mentioned it at the end of Custom notations readme section.

I'm using subclass of MaskedTextFieldDelegate, I created some custom inits for customNotations

You don't need to subclass, actually. MaskedTextFieldDelegate has a corresponding public variable customNotations, and you just assign your list of notations to it.

Also, now I see with this approach you'll gain another problem with your extracted value. To be specific, this problem: 1234123412341234 999 — an unnecessary space.

BUT there exists an another approach you may incorporate to define the value is complete. Mask instances and the wrapper MaskedTextFieldDelegate provide a series of calculated metrics for the text and for the extracted value, like acceptableTextLength, totalTextLength, etc.

MaskedTextFieldDelegate.acceptableValueLength() will return 16 in your case, so you could compare the length of the extracted value to it in order to define typing is completed.

Alright, but it's possible to include only blank space in the Compiler (along with Numbers and Letters)?

In order to define behavior, Compiler needs to know the nature of ellipsis preceding character:

[A…]
 ^ this one defines, what symbols are accepted

For now, Compiler is limited to the basic set of A a 0 9 - _. Custom notations do not work when it comes to elliptical masks, this is a feature to be implemented.

from input-mask-ios.

caioremedio avatar caioremedio commented on August 18, 2024

Oh, I forgot about that. I even mentioned it at the end of Custom notations readme section.

Oh my bad, didn't notice that.

You don't need to subclass, actually. MaskedTextFieldDelegate has a corresponding public variable customNotations, and you just assign your list of notations to it.

No, i'm not subclassing just for custom notation, I'm using for other approaches (overriding UITextField methods). I've just comment that because I thought auto-completion not working was a bug, so I just wrote everything I was doing.

MaskedTextFieldDelegate.acceptableValueLength() will return 16 in your case, so you could compare the length of the extracted value to it in order to define typing is completed.

Awesome, worked like a charm. So instead checking if completed == true, now I should rely on value.count > MaskedTextFieldDelegate.acceptableValueLength() right? I tested here and seems to work on all cases.

Custom notations do not work when it comes to elliptical masks, this is a feature to be implemented.

Gotcha. In the meantime gonna use default UITextFieldDelegate for that.

In order to define behavior, Compiler needs to know the nature of ellipsis preceding character:

Oh what I mean was, instead of implementing custom notations (if takes too much work) with ellipsis, just implement blank space character.

Thanks again!

from input-mask-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.