Android Question [B4X] B4XFloatTextField - hide password in code.

MrKim

Well-Known Member
Licensed User
Longtime User
I have a b4xpage that displays, among other things, a password. I am using the feature that allows you to view the password. Unfortunately the next time you open that page the password is still visible.

I would like to hide the password in code - in B4A/J/i. I looked for a property but couldn't find one.

Thanks for any help.
 

LucaMs

Expert
Licensed User
Longtime User
However I did not understand the question.


You have a B4XFloatTextField; click the reveal button to be able to read the password. So you open another page and when you go back to the first you want the password to be "hidden" again. How come???
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Have considered using two identical views on top of each other. Only one is visible. One has a password reveal, the other doesn't.
You can then control which one you want to show at what time. When focus is lost, copy text to the alternative view.

Note, I did look at the source code for B4XFloatTextfield (Anywhere, Internal library, XUI View.B4XLib). The internal switch to determine reveal or hide occurs in multiple places, so a simple modification is not in the cards.

I do see the need for this effect. After leaving a field, it is reassuring that the password is hidden again. It also let's you force one-time entry of password.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Correction: I modified B4XFloatText to make SwitchFromPasswordToRegular Public, and changed the name to ModB4XFloatTextfield.

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ModFloatTextField1 As ModFloatTextField
   
    Private passwordEntered As Boolean
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

Private Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Private Sub ModFloatTextField1_FocusChanged(hasFocus As Boolean)
    If hasFocus = False Or passwordEntered Then
        ModFloatTextField1.SwitchFromPasswordToRegular(False)
        passwordEntered = True
    End If
End Sub

Add the attached file to the parent directory in a B4XPages project and add as existing module to the project.
 

Attachments

  • ModFloatTextField.bas
    14.2 KB · Views: 159
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see B4X:

B4X:
Private Sub B4XPage_Disappear
    Log("LoginPage: B4XPage_Disappear")
    CallSub2(txtUserPaword, "SwitchFromPasswordToRegular", False)
End Sub
 

Attachments

  • 1.gif
    1.gif
    199.2 KB · Views: 212
  • B4XLogin.zip
    18.1 KB · Views: 168
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
incorrect:
Correction: I modified B4XFloatText to make SwitchFromPasswordToRegular Public, and changed the name to ModB4XFloatTextfield.

use:
B4X:
CallSub2(txtUserPaword, "SwitchFromPasswordToRegular", False)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
CallSub2(txtUserPaword, "SwitchFromPasswordToRegular", False)
Is this a hack or a workaround. How does one know that there is such sub named: SwitchFromPasswordToRegular in the B4XFloatTextField class module without actually unzipping and sifting through its code in the XUI Views library. Is there a more intuitive way to manipulate the password. It is nevertheless better than creating a new class: ModFloatTextField
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Is this a hack or a workaround.
No.
is a solution

How does one know that there is such sub named: SwitchFromPasswordToRegular in the B4XFloatTextField class module without actually unzipping and sifting through its code in the XUI Views library.

you can use or modify these tools, to see the events and functions of B4XLib.


I think this tool is being updated for B4XLib.

 
Last edited:
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
However I did not understand the question.


You have a B4XFloatTextField; click the reveal button to be able to read the password. So you open another page and when you go back to the first you want the password to be "hidden" again. How come???
The user has access to lots of passwords for multiple sources. when he "Closes" the page he may be opening another page to a completely different source with a different password. There is the possibility that one pw is quite sensitive, and another, not so much. He might have someone looking over his shoulder and he is fine with that person seeing one PW - perhaps he is giving it to them. The next one he opens - no. The user may have looked at the screen when no one was in the room with him, the next time, someone else is there. He could be opening the page to give someone information other than the password, ie. web address/address/phone number.
 
Last edited:
Upvote 0
Top