我想要实现的是将处理程序/函数设置为 Enter 事件,但是就我而言,我想调用两个不同的函数,因此我的计划是设置另一个输入事件以具有 ctrl:true
配置/属性。但这是行不通的,唯一起作用的是最后声明的那个人(因为这是编译器从头到尾读取代码的方式)。
下面是我的代码的简短预览:
Ext.define('mynamespace'{
extend: 'Ext.window.Window',
alias: 'widget.myalias',
requires: [ //all my requires here]
modal: true,
keyMapEnabled:true,
keyMap: {
Enter: { //this works if I don't have the keyMap after this
handler: 'myfunction'
},
Enter: { //this is the one that only works since this is the last event that is initialized after the screen/window is rendered/loaded
handler: 'myhandler',
ctrlKey: true
}
}
});
我在https://docs.sencha.com/extjs/6.5.1/modern/Ext.mixin.Keyboard.html#method-getKeyMap上尝试过,但是对我而言却没有用。
答案 0 :(得分:2)
不能。最好的办法是在处理程序和委托中检查事件:
handler: 'onEnter',
// Later
onEnter: function(e) {
if (e.ctrlKey) {
this.onEnterWithCtrl();
} else {
this.onEnterWithoutCtrl();
}
}