我在Enter
上编写此代码以进行提交 {
fieldLabel : 'Password',
name : 'j_password',
inputType : 'password',
allowBlank : false,
listeners : {
'render' : function(cmp) {
cmp.getEl().on('keypress', function(e) {
if (e.getKey() == e.ENTER) {
submitform();
}
});
}
}
}
我需要对快捷键进行哪些更改,例如Save(Ctrl + S)
,Paste(Ctrl +P)
,打开(Ctrl + O)
,Exit(Ctrl +X)
答案 0 :(得分:2)
您需要使用KeyMap编写适当的处理程序来完成工作。 Ext 4代码片段可能如下 -
Ext.onReady(function () {
var map = new Ext.util.KeyMap(document,{
key: [VALUES-ASCII], // this works,
fn: function(){ alert('key was pressed.!'); }
}
);
});
答案 1 :(得分:1)
我想,您将通过此代码解决您的问题
我提出了许多方法。
您从绑定中选择合适的一个:[{}]
scope : this,
listeners : {
afterrender: function(window, options) {
this.keyNav = new Ext.util.KeyMap({
target: window.el,
binding: [{
key: [10,13],
fn: function(){
alert("Return was pressed");
}
}, {
key: "abc",
fn: function(){
alert('a, b or c was pressed');
}
}, {
key: "\t",
ctrl:true,
fn: function(){
submitform();//'Control + tab was pressed
}
}, {
key: "m",
ctrl:true,
fn: function(){
submitform();//'Control + m was pressed
}
}],
scope: this
});
}
}