pin entry

You must Login before you can answer or comment on any questions.

Hi am creating a view which show how many digits have been entered of my pin entry screen, the pin entry screen consists of 10 buttons labeled 0 - 9 and when a button is pressed a dot is displayed above the button keypad. but it seems to move the dot along instead of adding another. I think this is not a good way of achieving this but i can think of another way. my current code:

var self = Ti.UI.createWindow({
        backgroundColor:'white',
        layout: 'vertical'
    });
 
    var pin = [];
    var dot = Ti.UI.createLabel({
        text: ".",
        width: "25%",
        font: {
            fontSize: 100 }
    });
 
    var press = Ti.UI.createWindow({
        backgroundColor:'red',
        height: 100,
        layout: 'horizontal'
    });
 
    self.add(press);
    var butView = Ti.UI.createView({
        backgroundColor:'white',
        layout: 'horizontal'
    });
 
    var but1 = Ti.UI.createButton({
        height: 90,
        width: "33%",
        title: "1"
 
    });
    but1.addEventListener('click',function(e){
        pin.push(1);
        if(pin.length > 3){
            alert(pin[0]+","+pin[1]+","+pin[2]+","+pin[3]);
        }
        press.add(dot);
    });
 
 
    self.add(butView);
    self.open();
Please note I have taken out most button as the code is long but they are a repeat of but1.

As you can see I add the dot to the view when a button is pressed. but this just moved the dot allong.

1 Answer

Accepted Answer

Titanium doesnt work like that.... you gotta create a new "dot" each time you add it... you are using the same "dot" always so thats why it moves along... just move your dot creation inside the listener...so each time you listen a "click" event you create a dot and then add it to the view.

Your Answer

Think you can help? Login to answer this question!