Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Last active October 24, 2016 11:35
Show Gist options
  • Save hansemannn/58aff0f5df455981298347815b68071a to your computer and use it in GitHub Desktop.
Save hansemannn/58aff0f5df455981298347815b68071a to your computer and use it in GitHub Desktop.
var win = Ti.UI.createWindow();
var view = Ti.UI.createView();
var password = Ti.UI.createTextField({
width : Ti.UI.FILL,
height : 40,
font : {fontSize: 14, fontFamily:"Times"},
passwordMask : false,
hintText : "password",
backgroundColor: "#ccc",
autocorrect : false,
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
returnKeyType: Ti.UI.RETURNKEY_DONE
});
password.addEventListener("change", function(e) {
Ti.API.warn("changed to: " + e.value);
});
var label = Ti.UI.createLabel({
right: 10,
text: "Hide Password"
});
label.addEventListener("click", function() {
//e.cancelBubble = true;
if (password.passwordMask === true) {
label.text = "Hide Password";
//inject font here, but still not work
password.font = {
fontFamily:"Times",
fontSize: 14
}
password.passwordMask = false;
} else {
label.text = "Show Password";
password.font = {
fontFamily:"Times",
fontSize: 14
}
password.passwordMask = true;
}
});
password.add(label);
view.add(password);
win.add(view);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment