Android Question B4XFloatTextField filter characters allowed

tsteward

Well-Known Member
Licensed User
Longtime User
I'm loving the B4XFloatTextField and can't figure out how to limit what characters and text length the user can input.
My app will provide a string of the allowed characters and field length as this varies all the time.

Any help appreciated
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
If I recall correctly, the B4XFloattextfield exposes the underlying textbox as a property.
B4X:
ime.SetCustomFilter(B4XEdTxtCode.TextField, EdTxtCode.INPUT_TYPE_TEXT, chars)
Again, search the forum for IME you will find many helpful posts.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
If I recall correctly, the B4XFloattextfield exposes the underlying textbox as a property.
B4X:
ime.SetCustomFilter(B4XEdTxtCode.TextField, EdTxtCode.INPUT_TYPE_TEXT, chars)
Again, search the forum for IME you will find many helpful posts.
I have searched and I have not found a solution for me.

The parameters
EdTxtCode.INPUT_TYPE_TEXT is not valid
EdTxtCode.TextField.INPUT_TYPE_TEXT is also not valid
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
If you wish to use the constants, you will need to cast the B4XView to the appropriate view type:
B4X:
Dim poTxt As EditText
poTxt = B4XEdTxtCode.TextField ' view is B4XFloatTextField and the .TextField property is B4XView not EditText
ime.SetCustomFilter(poTxt, poTxt.INPUT_TYPE_TEXT, chars)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can get the standard textfiel by

B4X:
Dim et As EditText = B4XFloatTextField1.TextField
'modify "et" as needed
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Use the Tag property of the B4XFloatEdit With the Tag property in 10 characters for example the code would be:

B4X:
Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
    If New.Length > B4XFloatTextField1.Tag Then
        B4XFloatTextField1.Text = New.Substring2(0, B4XFloatTextField1.Tag)
    End If
End Sub

It should work.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Use the Tag property of the B4XFloatEdit With the Tag property in 10 characters
I think you are missing some code. It should be like this:. Please confirm or refute:
B4X:
Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
    If New.Length > B4XFloatTextField1.Tag Then   'the tag has the max number of characters
        B4XFloatTextField1.Text = New.Substring2(0, B4XFloatTextField1.Tag)
        Dim et As EditText = B4XFloatTextField1.TextField
        et.SelectionStart = et.text.Length
    End If
End Sub
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
The lines you mention serve to place the cursor at the end of the text.

The code I make only blocks the number of characters.

Your code seems much better. Thank you
 
Upvote 0
Top