titanium - 单击 "?"按钮时如何显示输入的密码

标签 titanium

我在钛 iPhone 应用程序中使用密码字段,如果用户按“?”,我需要显示输入的密码释放“?”后按钮并屏蔽密码字段按钮。我使用了这些代码

var password = Ti.UI.createTextField
({
   font : {fontSize : 15, fontType: 'HaveticaL TStd', fontWeight: 'roman'},
   hintText: "***************",
   top : 54,
   left : 107,
   height : 24,
   width : 153,
   passwordMask : true,
   color : "black",
   returnKeyType : Titanium.UI.RETURNKEY_DONE,
   zIndex : 5
});

我使用touchstart和touchend事件来显示密码,即当touchstart事件发生时将passwordMask设置为false,当touchend事件发生时将passwordMask重置为true。

passwordHintImg.addEventListener('touchstart',function(e){
    passwordTxt.passwordMask = false;
});
passwordHintImg.addEventListener('touchend',function(e){
    passwordTxt.passwordMask = true;
});

当密码字段模糊时效果很好,但如果密码字段聚焦,我按“?”按钮显示密码,我无法隐藏显示的密码

最佳答案

最后,我得到了输出

我使用标签来显示密码并将可见设置为 false,当 touchstart 事件发生时,我将 passwordShow Label 可见更改为 true 并将密码字段可见设置为禁用,当 touchend 事件发生时,我将密码字段可见重置为 true,passwordShow 标签可见错误。

var passwordShow = Ti.UI.createLabel({
    font : {fontSize : 15, fontType: 'HaveticaL TStd', fontWeight: 'roman'},
    top : 54,
    left : 107,
    height : 24,
    width : 153,
    visible : false,
    backgroundColor : 'transparent',
    color : "black",
    zIndex : 15
});
passwordShowVw.addEventListener('touchstart',function(e){
    if(passwordTxt.value.length > 0)
    {
        passwordTxt.visible = false;
        passwordShow.visible = true;
        passwordShow.text = passwordTxt.value;  
    }
});
passwordShowVw.addEventListener('touchend',function(e){
    if(passwordTxt.value.length > 0)
    {
         passwordShow.visible = false;
         passwordTxt.visible = true;
         passwordShow.text = '';
    }
});

关于titanium - 单击 "?"按钮时如何显示输入的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16538705/

相关文章:

image - Titanium:在不创建 ImageView 的情况下获取 png 高度

ios - 删除 TabGroup 选项卡标题并仅在适用于 iOS 的 Appcelerator 应用程序上显示图标

javascript - 钛 - 添加数字时的问题

javascript - Android 国际应用程序名称钛

Titanium Appcelerator 应用程序 (IOS) 发布问题

android-emulator - 钛应用程序与 Facebook 的集成

ios - 我正在尝试使用 xCode 4.4 构建存档应用程序,但出现此错误

javascript - ImageView - 图像类型无效?

ios - 角标(Badge)从未清除

android - 移动 Angular 用户界面失败