1. #1
    Ext JS Premium Member
    Join Date
    Feb 2008
    Posts
    10
    Vote Rating
    0
    ajitk is on a distinguished road

      0  

    Exclamation [FIXED][2.2] 'keyup' event not working for 'ComboBox'

    [FIXED][2.2] 'keyup' event not working for 'ComboBox'


    I tried using key up events. It works fine in text fields but doesnt work for combo boxes.

    Code:
     
        Ext.onReady(function() {
            var combo = new Ext.form.ComboBox({
            enableKeyEvents :true,
                listeners: {
                	keyup: function(){
                        console.log("key up: ",arguments);
                    },
                	keydown: function(){
                        console.log("key down: ",arguments);
                    }
                 }
            }); 
        	combo.render(Ext.getBody());
        });
    Should it be logged as a bug ?

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Yes, I would say it is a bug (I'll move this thread to the bug forum).

    The code that was added for enableKeyEvents conflicts with the onKeyUp handler of ComboBox.

    Suggested fix:

    Code:
    Ext.override(Ext.form.ComboBox, {
    	initEvents : function(){
    		Ext.form.ComboBox.superclass.initEvents.call(this);
    		this.keyNav = new Ext.KeyNav(this.el, {
    			"up" : function(e){
    				this.inKeyMode = true;
    				this.selectPrev();
    			},
    			"down" : function(e){
    				if(!this.isExpanded()){
    					this.onTriggerClick();
    				}else{
    					this.inKeyMode = true;
    					this.selectNext();
    				}
    			},
    			"enter" : function(e){
    				this.onViewClick();
    				this.delayedCheck = true;
    				this.unsetDelayCheck.defer(10, this);
    			},
    			"esc" : function(e){
    				this.collapse();
    			},
    			"tab" : function(e){
    				this.onViewClick(false);
    				return true;
    			},
    			scope : this,
    			doRelay : function(foo, bar, hname){
    				if(hname == 'down' || this.scope.isExpanded()){
    				   return Ext.KeyNav.prototype.doRelay.apply(this, arguments);
    				}
    				return true;
    			},
    			forceKeyDown : true
    		});
    		this.queryDelay = Math.max(this.queryDelay || 10,
    				this.mode == 'local' ? 10 : 250);
    		this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
    		if(this.typeAhead){
    			this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
    		}
    		if((this.editable !== false) && !this.enableKeyEvents) {
    			this.el.on("keyup", this.onKeyUp, this);
    		}
    		if(this.forceSelection){
    			this.on('blur', this.doForce, this);
    		}
    	},
    	onKeyUp : function(e){
    		if(this.editable !== false && !e.isSpecialKey()){
    			this.lastKey = e.getKey();
    			this.dqTask.delay(this.queryDelay);
    		}
    		Ext.form.ComboBox.superclass.onKeyUp.call(this, e);
    	}
    });
    Last edited by Condor; 3 Sep 2008 at 9:27 PM. Reason: Fixed this.enableKeyEvents

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Location
    Bangalore
    Posts
    26
    Vote Rating
    0
    arunpjohny is on a distinguished road

      0  

    Default


    I think

    Code:
    if((this.editable !== false) && !enableKeyEvents)
    should be
    Code:
    if((this.editable !== false) && !this.enableKeyEvents)

  4. #4
    Ext User jerrybrown5's Avatar
    Join Date
    Sep 2007
    Location
    Port St Lucie, FL
    Posts
    185
    Vote Rating
    0
    jerrybrown5 is on a distinguished road

      0  

    Default


    I confirmed that keypress and keyup events do not work--only keydown.

    Cheers, JB

    Also, the net effect of the following should be applied to the default action of a combo
    Code:
    listeners:{
      keydown:function(){
        (function(){
          if (this.getRawValue()==''){
            this.value='';
          }
        }).defer(200, this);
      }
    }

  5. #5
    Sencha User Saeven's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Canada
    Posts
    419
    Vote Rating
    1
    Saeven is on a distinguished road

      0  

    Default


    +1
    S. Alexandre Lemaire
    Senior Architect
    saeven.net consulting inc.

  6. #6
    Ext User
    Join Date
    Sep 2008
    Posts
    4
    Vote Rating
    0
    rubaiz is on a distinguished road

      0  

    Default


    Any progress on this issue, do we expect a fix anytime soon.. I dont want to hack into the library and change the code as suggested in the fix..

    As a last resort ill use keydown as that is working..

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,169
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The fix Condor has posted looks correct, pending testing we'll integrate it into the core.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  8. #8
    Ext User
    Join Date
    Feb 2009
    Location
    Ukraine, Kyiv
    Posts
    27
    Vote Rating
    0
    astat is on a distinguished road

      0  

    Question


    HI,

    sorry, but i don't understand how to use this fix.
    i put it into my code - but nothing changes(((

    can somebody help?
    10x

  9. #9
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    [ friendly bump ]

  10. #10
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    fixed by @evant in SVN for both the 2.x and 3.x branches:
    http://extjs.com/forum/showthread.php?t=70991