
-----------------------------------
theuberk
Mon Jan 09, 2006 6:54 pm

Passwords in textfields?
-----------------------------------
I was just wondering how I would input a password in a textfield. I know that I can use getch and save the character in a string and then put a * in place of the character, but how would I do this in a textfield?

-----------------------------------
pavol
Mon Jan 09, 2006 8:08 pm


-----------------------------------
im not entirely sure, but you might be able to check every time a key is pressed and when it is, store the value of the key in a varibale. and then insead of writing the letter in the textfield you write an *. then you'd also have a variable counting how many keys have been pressed (letters have been entered), so the program knows how many * to put in the textfield.
hope it helps (and i hope it's at least possible) :D

-----------------------------------
Cervantes
Mon Jan 09, 2006 9:26 pm


-----------------------------------
[url=http://www.compsci.ca/v2/viewtopic.php?t=9329]You want to make your own textfields? ;)

-----------------------------------
theuberk
Mon Jan 16, 2006 6:58 pm


-----------------------------------
Thanks for your help guys. I figured it out! Here's the procedure if anyone wants to use it:


tf = the text field widgit ID
text = the variable in which you'd like to save the inputted text



procedure HideText (tf : int, var text : string) 
    var tftext : string := GUI.GetText (tf)
    var current : string := ""
    for i : 1 .. length (tftext)
        if tftext (i) not= "*" then
            text := text + tftext (i)
        end if
    end for

    if length (tftext) < length (text) then
        for i : 1 .. length (text) - 1
            current := current + text (i)
        end for
        text := current
    end if

    var newText : string := "*"
    for i : 1 .. length (tftext)
        if i 