B4A Library [Lib] Masked EditText

This EditText fixes a few issues with the standard EditText and adds new features:
- Filter: you can transform any input before the text is changed;
- Mask: you can define an input mask;
- Read-only: you can protect your EditText against changes;
- Floating hint: the hint moves above the EditText when the user starts typing;
- Error popup: you can display a message in a popup to warn the user:

met.png


v1.1:
- It is now a custom view supported by the designer
- I fixed a bug when Format was set after WithSuggestions

v1.2:
- I moved the CompactText function from the example to the library;
- I fixed a bug with SelectionStart;
- I fixed a bug when InputType is set to NONE.

v1.3:
- WithSuggestions works now as expected on Samsung devices.
- Suggestions are automatically disabled in password mode.

v1.4:
- I added the EnableFloatingHint function;
- I added the custom view properties for the designer.

v1.41:
- I improved the animation of the floating hint;
- I fixed an issue with the hint color.

v1.42:
- I fixed a bug with the floating hint when the EditText is moved.

v1.5:
- I rewrote the code of floating hints to make it more robust and fix a few issues;
- I added the SetFromHTML function.

v1.51:
- A few properties set in the designer were not taken into account.

v1.52:
- There was an issue with the background drawable as it was set by default by the designer to a white colored drawable. The support of this property in the designer was removed to keep the original default background.

This library does not work with Android versions < 2.
 

Attachments

  • MaskedEditText v1.52.zip
    24.9 KB · Views: 2,503
  • Java source - MaskedEditText.zip
    9.2 KB · Views: 905
  • MaskedEditText v1.53.zip
    25.2 KB · Views: 1,488
Last edited:

Guenter Becker

Active Member
Licensed User
thank you will mention it in the future.
 

RVP

Active Member
Licensed User
Longtime User
I have run into an issue with this library. I have an app I wrote for a client a couple of years ago, recently they installed it on a phone with a lower resolution that what they had been using and discovered a display issue with some fields. One was using Another Date Picker it was resolved here (https://www.b4x.com/android/forum/threads/problem-with-anotherdatepicker.112921/#post-704920 ) In Post #14.

The second was Masked Edit Text Fields.

In this case I seem to have tracked the issue down to the field ignoring the Padding parameter. I have attached a sample program that shows the issue. My test phone has a resolution of 2160x1080, if you try it on another phone you may have to adjust the box size to see the issue appear.

It consists of an Edit Field, and a Masked Edit Field. Both have the Padding set to the same value, however the display of the text in the field is different. What I noticed, is that if on the Edit Field I blank out the padding values, it then displays the same as the MET field. So it appears the MET is ignoring this setting and just using some default.,

MET.png
 

Attachments

  • MET.zip
    9.6 KB · Views: 253

Informatix

Expert
Licensed User
Longtime User
I have run into an issue with this library. I have an app I wrote for a client a couple of years ago, recently they installed it on a phone with a lower resolution that what they had been using and discovered a display issue with some fields. One was using Another Date Picker it was resolved here (https://www.b4x.com/android/forum/threads/problem-with-anotherdatepicker.112921/#post-704920 ) In Post #14.

The second was Masked Edit Text Fields.

In this case I seem to have tracked the issue down to the field ignoring the Padding parameter. I have attached a sample program that shows the issue. My test phone has a resolution of 2160x1080, if you try it on another phone you may have to adjust the box size to see the issue appear.

It consists of an Edit Field, and a Masked Edit Field. Both have the Padding set to the same value, however the display of the text in the field is different. What I noticed, is that if on the Edit Field I blank out the padding values, it then displays the same as the MET field. So it appears the MET is ignoring this setting and just using some default.,

View attachment 87621
I just released a new version (1.53) to fix this issue. The padding set with the designer was not took into account.
Thanks for the report and for the sample program.
 

RVP

Active Member
Licensed User
Longtime User
Thanks, I’ll give it a try.

Edit: Works fine now.
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
I'm using your MET and have set the Input Type in the Designer to use CAPS.
I'm expecting the first letter of each word to be capitalized. It is not.

I read posts #88 and 89.

So I set the Input Type to use TEXT and set the Input Type to CAPS, of the view, in the code.
Still no capitalized words.

I have the latest version of the library: 1.53
I have the latest version of B4A: 12.20

What am I doing wrong?

Thanx,
Mark Stuart
 

Guenter Becker

Active Member
Licensed User
Please Notice!
The Input Type of an Edit Tet View does only tell the IME Keyboard which keys to present and which not. In case that not presented keys can't be pressed they can't also be inputted in the text property by keyboard.
Switching the keyboard mode from lower to uppercase is done only by the shift key or by sending an upper or lowercase char to the text property.
As I know there is no automatic capitalizing.
 

mfstuart

Active Member
Licensed User
Longtime User
Hi Guenter,
The MET view has a property called InputType. which allows for setting of the input type. That's what I'm referring to.
This specified property does not work as specified, or, which allows me to use.
That's what I'm writing about.

I think what you are referring to is something else, which I will look into trying - IME.

Thanx,
Mark Stuart
 

Informatix

Expert
Licensed User
Longtime User
I'm using your MET and have set the Input Type in the Designer to use CAPS.
I'm expecting the first letter of each word to be capitalized. It is not.

I read posts #88 and 89.

So I set the Input Type to use TEXT and set the Input Type to CAPS, of the view, in the code.
Still no capitalized words.

I have the latest version of the library: 1.53
I have the latest version of B4A: 12.20

What am I doing wrong?

Thanx,
Mark Stuart
INPUT_TYPE_TEXT_WITH_CAPS capitalizes only the first word of each sentence. If you type a period at the end of a word, for example, the first letter of the next word will be capitalized. Having a capital letter at the beginning of each word has less practical use in everyday use and has not been implemented.
 

mfstuart

Active Member
Licensed User
Longtime User
@Informatix,
"Having a capital letter at the beginning of each word has less practical use in everyday use and has not been implemented."

I beg to differ on your statement:
eg: I would want the first letter of each typed word to be capitalized. Such as in this situation, where the MaskedTextField.InputType = INPUT_TYPE_TEXT_WITH_CAPS
Company Name, Street Name, Building Name, etc.

With this property, I'm assuming it supports what I'm referring to?

Regards,
Mark Stuart
 

mfstuart

Active Member
Licensed User
Longtime User
Just opened the MaskedEditTextWrapper.java file and discovered this on line 304:
public static final int INPUT_TYPE_TEXT_WITH_CAPS = InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
I think the current InputType of "INPUT_TYPE_TEXT_WITH_CAPS", needs to renamed to the bold text in the java file - referenced in my previous sentence.

HTH,
Mark Stuart
 
Top