Password Field

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 246
Joined: Tue Jun 30, 2009 11:15 pm

Password Field

Post by SirWobbyTheFirst » Mon Jul 05, 2010 6:38 pm

Hello again.

I am sorting out my logon system and would just like to know how to use the ImageSource property to change the character inputted into the field to a bullet, I tried a stack before which trapped the RawKeyDown and KeyDown messages and places the character into a separate property but doesn't quite work if I paste a value into the field.

So if someone could give me a hand, I would really appreciate it, I found something which did it before but the hard drive packed in afterward and the favourite link vanished.

Thanks, Michael.

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Contact:

Re: Password Field

Post by Curry » Tue Jul 06, 2010 7:50 am

By all means use the imageSource for a fancier bullet if desired (either put a character after the field text and then set the imagesource of the last char to your image, or use htmlText) but it's also possible to use a text bullet character, and many password fields out there in the software and web word simply use asterisks, so that might make your job a lot easier.
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Password Field

Post by Mark » Wed Jul 07, 2010 4:00 pm

Hi Michael,

You will find a complete password widget here. Just scroll down a little bit.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 246
Joined: Tue Jun 30, 2009 11:15 pm

Re: Password Field

Post by SirWobbyTheFirst » Wed Jul 07, 2010 8:05 pm

Ah thank you Mark. :)

fleo
Posts: 5
Joined: Sat May 12, 2012 8:22 am

Re: Password Field

Post by fleo » Sat May 12, 2012 8:26 am

Hi, I recentely got the same problem. This is how I solved it. The following script is in the password input field:

on KeyUp
repeat with x = 1 to the number of chars of me
set the imageSource of char x of me to "bullet"
end repeat
pass KeyUp
end KeyUp

on pasteKey
paste
repeat with x = 1 to the number of chars of me
set the imageSource of char x of me to "bullet"
end repeat
end pasteKey

(where "bullet" is the name of an imported image resource).

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: Password Field

Post by tzenobite » Sat May 12, 2012 9:34 am

why not using numtochar(165) for the bullet char?

edit: this is how i fake the password field on the iphone ios
i use two field, one with the "bulletted" text and another that stores the clear text (fld "password")
after two seconds the last key pressed the last char in the field is "crypted" just like in the ios appears
the image "x autore" is a little white x in a gray circle, as in the text field of the iphone


on mouseup
set the locktext of fld "username" to true
set the locktext of me to false
put "" into me
select the text of me
put "" into fld "password"
end mouseup

on openfield
put "" into me
hide image "x autore"
end openfield

global idletime

on keyup
show image "x autore"
put last char of me after fld "password"
if (number of chars of me > 1) then put numtochar(165) into char ((number of chars of me)-1) of me
select after last char of me
global idletime
put the seconds into idletime
end keyup

on idle
if the locktext of me = true then exit idle
if (me) = "" then exit idle
put the seconds - idletime into pausa
if pausa = 1 then
put the seconds into idletime
put last char of me after fld "password"
put numtochar(165) into last char of me
end if
end idle
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

fleo
Posts: 5
Joined: Sat May 12, 2012 8:22 am

Re: Password Field

Post by fleo » Sat May 12, 2012 11:40 am

numchar(165) is a pretty good idea, thanks!

I tried your script. It works generally fine but I think it has some slight issues, though.
If you type fast, very fast, some chars won't be crypted (I'm running the application on a desktop environment, not on the iphone).
If you paste a string, instead of typing it char by char, it won't be crypted as well (as originally noticed by the author of the thread).

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Password Field

Post by Mark » Sat May 12, 2012 11:52 am

Hi,

It is really difficult to make a really good password field. I worked on mine for several months and it is still not perfect, but it is good enough for use in commercial products. See the link I provided earlier.

If you don't want to donate for the password field, then I think using imageSource is the best alternative, because it avoids having to deal with all kinds of possible user actions.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: Password Field

Post by tzenobite » Sat May 12, 2012 12:54 pm

good point regarding the "paste" action
try this, in the idle handler

Code: Select all

if (number of chars of me > 1) then 
repeat with i=1 to ((number of chars of me)-1
put numtochar(165) into char i of me
end repeat
(i'm away from my home)
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

tzenobite
Posts: 57
Joined: Sun Dec 04, 2011 3:59 pm

Re: Password Field

Post by tzenobite » Sun May 13, 2012 3:50 pm

update field
pasting text on it doesn't work
enjoy it :)
Attachments
password.livecode.zip
(5.41 KiB) Downloaded 651 times
how many hypercardist are needed to change a light bulb? one to actually do it while at least a dozen more are finding out a slightly different way to do it

proudly hypertalking since 1989

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Password Field

Post by jacque » Sun May 13, 2012 9:40 pm

iOS input fields have a built-in password option. It might be easier to use that on mobile.

On desktop, I prefer the imagesource solution. It lets you read the text directly without having to store it somewhere else, and it's relatively easy to implement.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply