B4A Library Mask V1.0.0

Mask

This is a wrapper for this github project.

Version:
1
  • MaskEditText
    Methods:
    • Initialize (EventName As String, edit As EditText, mask As String)
    • Mask (format As String, text As String) As String
    • unMask (s As String) As String



B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private EditText1 As EditText
    Private EditText2 As EditText
    Private mask As MaskEditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    mask.Initialize("Mask",EditText1,"##.##.##.##.##")
    mask.Initialize("Mask",EditText2,"(##)####-#######")
End Sub
 

Attachments

  • MaskEx.zip
    7.1 KB · Views: 741
  • libMaskV1.0.0.zip
    4.1 KB · Views: 873
Last edited:

MaFu

Well-Known Member
Licensed User
Longtime User

ArminKH

Well-Known Member
I can't see why. To create a MaskedEditText with a mask, you just have to do:
myMET.Initialize("myMET")
myMET.Format = "##/##/#### ##:##"
Why is this simpler with this library ?
because by using this lib we can set a filter to an edittext which is created by designer or code directly
but if i remember exactly by using your lib we should at first dim a edittext as MaskedEditText Not Default EditText
see this
B4X:
Dim MaskedEditText1 As MaskedEditText
but with DonManfred Lib we can
B4X:
Private EditText1 As EditText
and also we can change the edittext's properties directly by designer but what about your lib?
for example hint color,...
i think this is simpler if we can set a filter to an edittext which is created by designer and use b4a default edittext not a modiffied version which is available by customview
this is just my idea maybe somebody are agree with me or not
thank u both for your libs
 

Informatix

Expert
Licensed User
Longtime User
because by using this lib we can set a filter to an edittext which is created by designer or code directly
but if i remember exactly by using your lib we should at first dim a edittext as MaskedEditText Not Default EditText
see this
B4X:
Dim MaskedEditText1 As MaskedEditText
but with DonManfred Lib we can
B4X:
Private EditText1 As EditText
and also we can change the edittext's properties directly by designer but what about your lib?
for example hint color,...
MaskedEditText can be set in the designer as a custom view, but due to limitations of the designer, you cannot edit all properties. Blame Erel for that. ;)
The problem with the B4A default EditText is its bugs. I fixed the most obvious in MaskedEditText. If I remember correctly, they affect the password mode on Samsung devices and the order of settings (in some cases, setting a parameter before another one cancels the previous setting).
 

ArminKH

Well-Known Member
MaskedEditText can be set in the designer as a custom view, but due to limitations of the designer, you cannot edit all properties. Blame Erel for that. ;)
The problem with the B4A default EditText is its bugs. I fixed the most obvious in MaskedEditText. If I remember correctly, they were related to the password mode on Samsung devices and to the order of settings (in some cases, setting a parameter before another one cancelled the previous setting).
yes i know this,my post is about simpler use and is not related to which lib is beter,as i said on above post this library just is simpler not exactly is better
thanx
 

Informatix

Expert
Licensed User
Longtime User
yes i know this,my post is about simpler use and is not related to which lib is beter,as i said on above post this library just is simpler not exactly is better
thanx
I didn't try the Manfred's lib so I'm totally unable to say which one is better. I see just that's less featured.
I understand well the usefulness of extending the EditText to benefit from the support in the designer. I agree totally on that point.
 

Anser

Well-Known Member
Licensed User
Longtime User
Is there any way to get/retrieve the unmasked text

For Eg.
B4X:
Mask.Initialize("Mask",EdtSprDiscPer,"##.## %")

The value entered in the EditBox is displayed as expected ie 23.56 %

Is there any way to get the value as 23.56 from the EditText instead of 23.56%.

This will be needed when we write the value to the database.

When I checked MsgBox(EdtSprDiscPer.Text,"Test") it is showing as 23.56 %

Regards
Anser
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub EditText2_TextChanged (Old As String, New As String)
    Log(New&" -> "&mask.unMask(New))
End Sub
 

Anser

Well-Known Member
Licensed User
Longtime User
I use the following
B4X:
Mask.Initialize("Mask",DiscountPercentage,"##.## %")

My intention is to Key in 12.36
I Key in the following the above said 12.36

The Mask.UnMask is returning 1236 %

What I need is 12.36

I believe that there should be a way to get this done

Regards
Anser
 

Anser

Well-Known Member
Licensed User
Longtime User
I tried removing %
Even then, the result of UnMasK is not what I am expecting.
May be this is the expected behavior of this Lib and I am using the wrong lib for my purpose.

The value entered in the EditText is 12.36 When I UnMask it is giving 1236
(I can arrive at the value 12.36 by dividing 1236/100 )

My requirement:-

In the EditBox the user should enter a value between 0.00 and 99.99 ONLY
Over and above that, the user visually should see and understand that the text box is going to accept only 2 digits a dot and then 2 decimals
I wonder how others manage these kind of Editbox's requirements

Thanks & Regards

Anser
 
Last edited:

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

How can i use space char in mask text.
I need "# (###) ###-####" but it works well only with "#(###)###-####")

note : user must not write to space char
 

Jose Luis Barajas

Member
Licensed User
Longtime User
Hi Don

I test your Wrapp today with this mask

mask.Initialize("Mask",EditText1,"##:##")

And the result on the app its 12:::

Also if I changed the mask to

mask.Initialize("Mask",EditText1,"##)##") ' Only for test this works!

Can you review your wrap for correct this bug? the error was with the ":" character.

Also, I really like to make wraps, If you can teach us, how to correct this, of course if you have time!

Any way thanks for your response!

Buen dia, saludos!!!
 
Top