B4A Library Mask V1.0.0

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Jul 12, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    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



    Code:
    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
     

    Attached Files:

    Last edited: Jul 12, 2015
    iz0ndg, peacemaker, SJQ and 9 others like this.
  2. NJDude

    NJDude Expert Licensed User

    Just in case you missed it, there's also an alternative HERE
     
  3. Johan Schoeman

    Johan Schoeman Expert Licensed User

    DonManfred likes this.
  4. Peter Simpson

    Peter Simpson Well-Known Member Licensed User

    DonManfred likes this.
  5. ArminKH

    ArminKH Well-Known Member

  6. MaFu

    MaFu Well-Known Member Licensed User

    DonManfred and ArminKH like this.
  7. ArminKH

    ArminKH Well-Known Member

    Yes,my mean is just for filtered edit texts
     
  8. Informatix

    Informatix Expert Licensed User

    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 ?
     
    NJDude and ArminKH like this.
  9. ArminKH

    ArminKH Well-Known Member

    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
    Code:
    Dim MaskedEditText1 As MaskedEditText
    but with DonManfred Lib we can
    Code:
    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 likes this.
  10. Informatix

    Informatix Expert Licensed User

    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).
     
  11. ArminKH

    ArminKH Well-Known Member

    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
     
    DonManfred and Peter Simpson like this.
  12. Informatix

    Informatix Expert Licensed User

    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.
     
  13. Anser

    Anser Active Member Licensed User

    Is there any way to get/retrieve the unmasked text

    For Eg.
    Code:
    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
     
  14. DonManfred

    DonManfred Expert Licensed User

    Code:
    Sub EditText2_TextChanged (Old As String, New As String)
        
    Log(New&" -> "&mask.unMask(New))
    End Sub
     
    Peter Simpson likes this.
  15. Anser

    Anser Active Member Licensed User

    I use the following
    Code:
    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
     
  16. DonManfred

    DonManfred Expert Licensed User

    Dont use " %" in your mask
    or
    replace " %" with "" in the unmasked string
     
  17. Anser

    Anser Active Member Licensed 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: Oct 9, 2015
  18. ykucuk

    ykucuk Active Member Licensed 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
     
  19. Jose Luis Barajas

    Jose Luis Barajas Member Licensed 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!!!
     
  20. DonManfred

    DonManfred Expert Licensed User

    learn java
    search the forum for examples (there are some)
    browse the developerforum for more info
     
Loading...