F fred-han Member Licensed User Longtime User Oct 29, 2019 #1 Is there a way to set the cursor in the field at a defined position like "MaskedEditText"-Lib do? I want to create a field with some kind of mask and the way "MaskedEditText" do is quit good an easy, but the style of the field is not the same as "FloatLabeledEditText" and i want to have always the same look. Any suggestions? Perhaps is it possible to extend the B4XFloatText.b4xlib?
Is there a way to set the cursor in the field at a defined position like "MaskedEditText"-Lib do? I want to create a field with some kind of mask and the way "MaskedEditText" do is quit good an easy, but the style of the field is not the same as "FloatLabeledEditText" and i want to have always the same look. Any suggestions? Perhaps is it possible to extend the B4XFloatText.b4xlib?
Erel B4X founder Staff member Licensed User Longtime User Oct 29, 2019 #2 Code: Copy Dim et As EditText = B4XFloatTextField1.TextField 'work with et.SetSelection It is not simple to create a "mask feature" and unless it works perfectly then it is likely to cause more harm than good. In many cases it is simpler to check whether the input is valid when the focus is lost or when the user clicks on a button. Another option is to handle the TextChanged event and set the border to be red when the input is invalid. Upvote 0
Code: Copy Dim et As EditText = B4XFloatTextField1.TextField 'work with et.SetSelection It is not simple to create a "mask feature" and unless it works perfectly then it is likely to cause more harm than good. In many cases it is simpler to check whether the input is valid when the focus is lost or when the user clicks on a button. Another option is to handle the TextChanged event and set the border to be red when the input is invalid.
F fred-han Member Licensed User Longtime User Oct 29, 2019 #3 I want to create an input that looks like 09/2012 (month/year) that looks the same way as BFTF.. When the user enters 2 signs, i add the "/" and he can type the rest. I tried the following: Code: Copy Sub ed_fz_tuev_TextChanged (Old As String, New As String) If New.Length = 2 Then New = New & "/" ed_fz_tuev.Text = New Dim et As EditText = ed_fz_tuev.TextField et.SelectionStart = 3 End If End Sub That works .... but if i use the backspace from keybord, the "/" sign would not be deleted. I think "SelectionStart" is the reason ... How can i manage this? Is there a way for me to add the properties "SelectionStart" and "SelectionEnd" to B4XFloatTextField.bas ?? Upvote 0
I want to create an input that looks like 09/2012 (month/year) that looks the same way as BFTF.. When the user enters 2 signs, i add the "/" and he can type the rest. I tried the following: Code: Copy Sub ed_fz_tuev_TextChanged (Old As String, New As String) If New.Length = 2 Then New = New & "/" ed_fz_tuev.Text = New Dim et As EditText = ed_fz_tuev.TextField et.SelectionStart = 3 End If End Sub That works .... but if i use the backspace from keybord, the "/" sign would not be deleted. I think "SelectionStart" is the reason ... How can i manage this? Is there a way for me to add the properties "SelectionStart" and "SelectionEnd" to B4XFloatTextField.bas ??
Erel B4X founder Staff member Licensed User Longtime User Oct 29, 2019 #4 fred-han said: Is there a way for me to add the properties "SelectionStart" and "SelectionEnd" to B4XFloatTextField.bas ?? Click to expand... Yes, but it is a mistake. I've already showed you above how you can access the internal EditText. Upvote 0
fred-han said: Is there a way for me to add the properties "SelectionStart" and "SelectionEnd" to B4XFloatTextField.bas ?? Click to expand... Yes, but it is a mistake. I've already showed you above how you can access the internal EditText.
F fred-han Member Licensed User Longtime User Oct 30, 2019 #5 Okay i will use the internal access to EditText. But the other problem is, that the "Backspace" from keyboard stops at the position i have set with "SelectionStart". What can i do to get the cursor delete the signs beyond this position? Upvote 0
Okay i will use the internal access to EditText. But the other problem is, that the "Backspace" from keyboard stops at the position i have set with "SelectionStart". What can i do to get the cursor delete the signs beyond this position?
Erel B4X founder Staff member Licensed User Longtime User Oct 30, 2019 #6 You should start a new thread for a new question. Upvote 0