PDA

View Full Version : Keyboard scrolling in comboboxes



Pedrolo
11 Dec 2007, 4:14 AM
Hi I'm using comboboxes as in this example (http://extjs.com/deploy/dev/examples/form/custom.html) to filter do a query to server and usually it returns a lot of results.
Initially I supposed keys pageUp an pageDown where mapped to move over the combobox list, but onli up and down where mapped so, I added them to the code.
It's quite simple and maybe I missed some details, but it works.
The code is added to ext-all.js (I added to ext-all-debug.js by comodity) to method initEvents in ComboBox definition:


Ext.form.ComboBox.superclass.initEvents.call(this);

this.pagination=this.pageSize!=0?this.pageSize:19;

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();
}
},
"pageUp" : function(e){
this.inKeyMode = true;
for(i=0;i<this.pagination;i++){
this.selectPrev();
}
},

"pageDown" : function(e){
this.inKeyMode = true;
for(i=0;i<this.pagination;i++){
this.selectNext();
}
},

"enter" : function(e){
this.onViewClick();
},

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