Comments (6)
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.
Alright, now elliptical masks support custom notations, too.
Check out the newest 3.4.1
.
from input-mask-ios.
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.
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.
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.
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)
- can you add tailplaceholder as parameter, like MaskedTexfieldDelegate(primaryFormat: [99] / [99], isTailPlaceholderVisible: true) HOT 3
- Move the list of countries to an external file… maybe?
- fix put when primaryMaskFormat "7 ([999])", if we use put("788", textfield) and if string first char is 7 mask will remove it, output: "7 88" HOT 8
- Update the wikis
- Obtain text field value without input-mask HOT 1
- first number of format is wrong with prefix HOT 2
- Being able to use the `UITextField` delegates HOT 11
- First number of mask(#104) HOT 17
- Automatic Caps Lock Activation Issue in MaskedTextField HOT 7
- [Question] How do I initially fill in the mask having only symbols for blanks? HOT 10
- [Question] Character Limit HOT 2
- IOS Objective-C Programmatically example HOT 1
- [!] Unable to determine Swift version for the following pods HOT 1
- Unable to use with single textField HOT 2
- How to define ${dynamic amount }/month in input mask HOT 1
- How to write uppercased text? HOT 2
- Number Formatting (Thousand Separator) HOT 3
- Poor performance when user types fast HOT 3
- can you make mask template always visible while user input text HOT 2
- My repo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from input-mask-ios.