You found a bug! We've classified it as EXTJSIII-135 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Dec 2009
    Posts
    5
    Vote Rating
    2
    silentsakky is on a distinguished road

      1  

    Default Ext.KeyMap problems with stopEvent flag

    Ext.KeyMap problems with stopEvent flag


    Ext versions tested:
    ExtJS 3.4.0

    Browser versions tested:
    Chrome (although the bug doesn't depend on browser types

    Description:
    When registering two different key bindings to same Ext.KeyMap object we can't set stopEvent: false in any of the bindings

    Code:
        var keymap = Ext.get('id1').addKeyMap();
        console.log(keymap.stopEvent);
        
        keymap.addBinding([{
            key : Ext.EventObject.DELETE,
            stopEvent : true,
            fn : function() {console.log('delete');}
        }, {
            key : 'a',
            ctrl : true,
            // this is not going to work, because first binding has already changed keymap.stopEvent flag to true
            stopEvent : false,
            fn : function() {console.log('ctrl + A');}
        }]);

    Live Example:Steps to reproduce:
    1. open above link
    2. write something in the textbox
    3. try to select text using ctrl + a


    Possible Fix:
    Code:
    Ext.override(Ext.KeyMap, {
         addBinding: function(config) {
            if(Ext.isArray(config)){
                Ext.each(config, function(c){
                    this.addBinding(c);
                }, this);
                return;
            }
            var keyCode = config.key,
                fn = config.fn || config.handler,
                scope = config.scope,
                stopEvent = config.stopEvent;
    
    
            if(!Ext.isDefined(stopEvent)) {
                stopEvent = this.stopEvent;
            }
    
    
            if(typeof keyCode == "string"){
                var ks = [];
                var keyString = keyCode.toUpperCase();
                for(var j = 0, len = keyString.length; j < len; j++){
                    ks.push(keyString.charCodeAt(j));
                }
                keyCode = ks;
            }
            var keyArray = Ext.isArray(keyCode);
            
            var handler = function(e){
                if(this.checkModifiers(config, e)){
                    var k = e.getKey();
    
    
                    if(keyArray){
                        for(var i = 0, len = keyCode.length; i < len; i++){
                            if(keyCode[i] == k){
                              if(stopEvent){
                                  e.stopEvent();
                              }
                              fn.call(scope || window, k, e);
                              return;
                            }
                        }
                    }else{
                        if(k == keyCode){
                            if(stopEvent){
                               e.stopEvent();
                            }
                            fn.call(scope || window, k, e);
                        }
                    }
                }
            };
            this.bindings.push(handler);
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,669
    Vote Rating
    747
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar