iOS Question B4XFloatTextField reveal password problem

davemorris

Active Member
Licensed User
Longtime User
Hi, Guys
I am using the B4XFloatTextField and have a strange problem when I select reveal passwords.

1. The B4XFloatTextField view is setup in Designer with password property checked.
2. This view (in the code) is attached to the keyboard along with a hide button by calling.
B4X:
Sub AddViewToKeyboard (view As Object, pnlHide As Object)
   Dim no As NativeObject = view
   no.SetField("inputAccessoryView", pnlHide)
End Sub

3. Running the code each time you select the B4XFloatTextField view the keyboard appears along with the Hide button (as expected).
4. However, when you click on the B4XFloatTextField reveal icon, the text is revealed but the Hide button vanishes.

Any suggestions - I think that the original link between the keyboard and the B4XFloatTextField view (with Hide) is lost - but I can't see how to detect this happening or fix it.

Kind regards
Dave
 

davemorris

Active Member
Licensed User
Longtime User
Hi Erel (thanks again for the quick response)

I thought that was the case - Well these custom views are intended to by customized - so I would like to have a go.

Looking at the code it appears B4XFloatTextField.SwitchFromPasswordToRegular() needs changing so it just replaces the masked text with the real text but does not create a new view - is it as simple as that or have I got the wrong end of the stick.

Kind regards
Dave
 
Upvote 0

davemorris

Active Member
Licensed User
Longtime User
Hi, Erel

Tried to modify B4XFloatTextFied.SwitchFromPasswordToRegular() it appears to work - (but not yet tried it with a hide keyboard button)
However, there is a problem when you switch back to hide text mode from reveal and start typing, the original characters are cleared out (It is ok going from Hide to reveal).


Modifications to B4XFloatTextField:
Private Sub SwitchFromPasswordToRegular (ToRegular As Boolean)
'    Dim text As String = mTextField.Text
'    Dim textcolor As Int = mTextField.TextColor
'    Dim Font1 As B4XFont = mTextField.Font
'    Dim oldfield As B4XView = mTextField
    
    Dim tf As TextField =  mTextField
    tf.PasswordMode = Not(ToRegular)
    If lblClear.IsInitialized Then
        If ToRegular = False Then
            lblClear.Text = Chr(0xE8F4)
            lblClear.Tag = "reveal"
        Else
            lblClear.Tag = "hide"
            lblClear.Text = Chr(0xE8F5)
        End If
        lblClear.BringToFront
    End If
    ToRegular = Not(ToRegular)
'    CreateTextFieldAll(Not(ToRegular), Font1, textcolor)
'    mTextField.Text = text
'    If lblClear.IsInitialized Then
'        If ToRegular = False Then
'            lblClear.Text = Chr(0xE8F4)
'            lblClear.Tag = "reveal"
'        Else
'            lblClear.Tag = "hide"
'            lblClear.Text = Chr(0xE8F5)
'        End If
'        lblClear.BringToFront
'    End If
'   
'   
'    If lblV.IsInitialized Then lblV.BringToFront
'    HintImageView.BringToFront
'    Base_Resize(mBase.Width, mBase.Height)
'    #if B4J
'    Dim tf As TextField = mTextField
'    tf.SetSelection(mTextField.Text.Length, mTextField.Text.Length)
'    #else if B4A
'    Dim et As EditText = mTextField
'    et.SelectionStart = mTextField.Text.Length
'    #end if
'    LastSwitchTextFieldTime = DateTime.Now
'    mTextField.RequestFocus
'    oldfield.RemoveViewFromParent
End Sub


Any suggestions.

Regards
Dave
 
Upvote 0

davemorris

Active Member
Licensed User
Longtime User
Hi, Erel
I have always been grateful for your's and the forum's assistance and I understand your warning
I don't recommend modifying the source code. You are on your own here..

However, in this situation I felt that I may have found an underlying problem with the B4XFloatTextField relating to its reveal/hide operation (particularly if you attempted to modify the code).

So I reverted back to using the original B4XFloatTextField view from the Library, only to find it did exactly the same thing as reported in
However, there is a problem when you switch back to hide text mode from reveal and start typing, the original characters are cleared out (It is ok going from Hide to reveal).

Kind regards
Dave
 
Upvote 0

davemorris

Active Member
Licensed User
Longtime User
HI, Erel
Thanks for the quick response - its the native text field - I will try to do a workaround (its also good to see its not my code - obviously remembering your warning).

I will keep you posted, if it deals with my original problem with the hide keyboard button.

Kind regards
Dave
 
Upvote 0
Top