Sencha touch 2 如何在sencha touch中使用enter键提交登录表单
我用的是senchatouch。我想在我的键盘上按回车键登录。任何人都可以知道答案吗?请帮助 这是我的密码Sencha touch 2 如何在sencha touch中使用enter键提交登录表单,sencha-touch-2,enter,Sencha Touch 2,Enter,我用的是senchatouch。我想在我的键盘上按回车键登录。任何人都可以知道答案吗?请帮助 这是我的密码 Ext.define('App.form.LoginForm', { extend: 'Ext.form.Panel', xtype: 'loginform', id: 'loginform', config: { items: [{ html: '<br><div style="text-align
Ext.define('App.form.LoginForm', {
extend: 'Ext.form.Panel',
xtype: 'loginform',
id: 'loginform',
config: {
items: [{
html: '<br><div style="text-align:center;"><i class="fa fa-lock fa-5x icon-fill"></div>'
},{
xtype: 'fieldset',
items: [{
xtype: 'textfield',
id: 'username_fld',
name: 'username_fld',
required: true
}, {
xtype: 'passwordfield',
id: 'password_fld',
name: 'password_fld',
placeHolder: 'Password',
required: true
}]
}, {
xtype: 'button',
name: 'login_btn',
itemId: 'logInButton',
text: 'Log In',
cls: 'x-form-fieldset'
}]
}
});
Ext.define('App.form.LoginForm'{
扩展:“Ext.form.Panel”,
xtype:'loginform',
id:'登录信息',
配置:{
项目:[{
html:“
”
},{
xtype:“字段集”,
项目:[{
xtype:'textfield',
id:'username\u fld',
名称:'username_fld',
必填项:true
}, {
xtype:'密码字段',
id:“密码\u fld”,
名称:'password_fld',
占位符:“密码”,
必填项:true
}]
}, {
xtype:'按钮',
名称:'login_btn',
itemId:“登录按钮”,
文本:“登录”,
cls:“x-form-fieldset”
}]
}
});
使用密码字段的键
事件,如下所示:-
refs: {
password: 'passwordfield[name="password_fld"]'
},
control: {
password : {
keyup: function(field, e){
if(e.event.keyCode === 13) {
console.log('Do login');
// Your login code goes here
}
}
}
}
谢谢你的回复,但按回车键时不满足if条件。在密码字段中获取密钥码…因此无法写入登录码…那么您在密钥码中获取的是什么。它在我的项目中工作。能够在密码字段中获得除enter键之外的键码…单击“a”时显示65…您应该在您的问题中加入您的解决方案,以便其他面临此问题的人可以获得帮助。
{
xtype: 'passwordfield',
id: 'password_fld',
name: 'password_fld',
placeHolder: 'Password',
required: true,
listeners: {
painted: function (field, e) {
document.addEventListener("keydown", myFunction, false);
}
}
}
function myFunction(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode == 13) { // charcode 13 for "entry" keyboard
evt.preventDefault();
var myApp = me.getApplication().getController('App');
myApp.login()
}
}