【问题标题】:How to create shortcut keys in extjs如何在extjs中创建快捷键
【发布时间】:2013-07-22 01:01:44
【问题描述】:

我编写此代码以在 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)这样的快捷键需要做哪些修改?

【问题讨论】:

    标签: javascript extjs dom-events extjs3


    【解决方案1】:

    您需要编写适当的处理程序来使用 KeyMap 完成这项工作。 ext 4代码sn-p可能如下-

    Ext.onReady(function () {
        var map = new Ext.util.KeyMap(document,{                
                key: [VALUES-ASCII], // this works,
                fn: function(){ alert('key was pressed.!'); }
            }
        );
    });
    

    This may Help

    【讨论】:

    • 我正在使用 Extjs 3.4 给我任何关于 extjs 3.4 的示例 Ext.util.KeyMap 在 Extjs 3.4 中不可用
    • Ext.keyMap 用于分机 3。
    【解决方案2】:

    我认为,您将通过此代码解决您的问题

    我给了很多方法。

    您从绑定中选择一个合适的:[{}]

                    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
                            }); 
                        }
                    }
    

    【讨论】:

    • 不错!这个去哪儿了?如何集成到 extjs 5 viewController 中?
    猜你喜欢
    • 2021-12-23
    • 2021-02-14
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多