Page 1 of 1

How to hide a password?

Posted: Sun Aug 26, 2012 11:47 am
by paulsr
Greetings:

I am developing an app which begins with a user having to login with a username and password.

I can't find any way to hide the password, with blobs or asterisks or something.

I've found links to code which is supposed to do this, but haven't managed to find the code itself.

I'm kind of surprised that LiveCode doesn't have an option (maybe in the Inspector) to say "this is a password field."

I've found "ask password" but that's not quite what I want. I rather not have an answer box popping up, after the user has entered a user name.

Can someone steer me in the right direction please...

TIA

--paul

Re: How to hide a password?

Posted: Sun Aug 26, 2012 12:19 pm
by LittleGreyMan
Hi Paul,

AFAIK, ask password is the only build-in command allowing this in LC. If it doesn't suits you, you have to manage it yourself, using a keydown handler.

Maybe somebody has already written such a piece of code and will chime in.

Did you have a look at the User samples?

Re: How to hide a password?

Posted: Sun Aug 26, 2012 12:31 pm
by jmburnod
Hi Paul,

It seems that is not easy to do it
some experiments here:
http://forums.runrev.com/phpBB2/viewtop ... ord#p56323
Best regards
Jean-Marc

Re: How to hide a password?

Posted: Sun Aug 26, 2012 4:57 pm
by dunbarx
Hi.

This has come up several times. I can't remember what happened.

Make a field named "f1". Put this into its script:

Code: Select all

on keydown var
   put numToChar(161) after me
   set the currentPassword of me to the currentPassword of me & var
end keydown

on mouseEnter
   put "" into me
   set the currentPassword of me to ""
end mouseEnter
In a button somewhere, place this into its script:

Code: Select all


on mouseup
   if the currentPassword of fld "f1" = the passWordData of fld "f1" then goAheadWithYourStuff
end mouseup
You need to set the passWordData of that field (another custom property) to the string of your choice.

Do you see how it works? Do you see that using the "delete" key is not managed? What are we going to do about that?

Craig Newman

Re: How to hide a password?

Posted: Sun Aug 26, 2012 5:34 pm
by Mark
Hi,

It is quite complicated to make a really good password field, but I think I've manage to make something that works. You can find it here, but a donation is required.

Kind regards,

Mark

Re: How to hide a password?

Posted: Sun Aug 26, 2012 6:18 pm
by wsamples
You could look at DropTools. One of the available tools is a password field. It's free and easy to add to your stack.

http://droptools.sonsothunder.com/produ ... ag-pw.irev

http://droptools.sonsothunder.com/moreinfo.irev
http://droptools.sonsothunder.com/all.irev

Re: How to hide a password?

Posted: Mon Aug 27, 2012 4:54 am
by paulsr
wsamples wrote:You could look at DropTools. One of the available tools is a password field. It's free and easy to add to your stack.

http://droptools.sonsothunder.com/produ ... ag-pw.irev

http://droptools.sonsothunder.com/moreinfo.irev
http://droptools.sonsothunder.com/all.irev
Thank you! That was what I found last week, failed to bookmark and couldn't relocate!

--paul

Re: How to hide a password?

Posted: Mon Aug 27, 2012 4:56 am
by paulsr
Oh dear. Looks like I even downloaded it. More coffee needed.

--paul

Re: How to hide a password?

Posted: Mon Aug 27, 2012 10:44 am
by paulsr
Okay, that works a treat.

But, would you know how to clear the displayed password field? If a user enters an incorrect password, I'd like to clear out the asterisks.

I have tried ...

Code: Select all

put empty into fld "aagPasswordField"
but this only clears the display, not the contents of the variable. So when the user enters a new password, it is concatenated onto the old one.

TIA

--paul

Re: How to hide a password?

Posted: Mon Aug 27, 2012 11:51 am
by paulsr
Hmmm, I've just realized that to achieve what I need (YMMV) there's a very simple method...

I don't care about password encryption, I just don't want it to be visible on-screen. So, I created two Text Entry Fields, let's call them PW and AST.

I made them the same size, I placed AST directly on top of PW, and disabled it.

Then I put the flwg code into PW...

Code: Select all

on rawKeyUp
   put "*********************" into t_stars
   put the len of fld "PW" into t_len
   put char 1 to t_len of t_stars into fld "AST"
end rawKeyUp
So the user actually types into PW but only sees the contents of AST, which contains asterisks.

That code could no doubt be more elegant but the solution works for me, and may help someone else.

--paul

Re: How to hide a password?

Posted: Mon Aug 27, 2012 8:24 pm
by jacque
I've tried all kinds of methods, but the password field I like best right now is this one:

http://runtime-revolution.278305.n4.nab ... 90644.html

This method is very easy to implement, and automatically takes care of everything a user might type into the field including backspaces, select all, delete, typing over a selection, etc. You don't need any code at all for those things, the engine does it for you.

Re: How to hide a password?

Posted: Tue Aug 28, 2012 2:40 am
by paulsr
Thank you Jacque, I'll try that...

--paul