PDA

View Full Version : Combobox tab press



prasanthsd
18 Feb 2010, 5:03 AM
Hi all

Im using a combobox in my application. By default tab key navigation are disabled throughout the application. For textboxes it works correctly. But for the combo box it spawns the blur event, is there any way to prevent that?


This is the code that prevents tab press:



Ext.EventManager.on(document,'keydown',function(e){
var keyID = (window.event) ? event.keyCode : e.keyCode;
switch(keyID){
case 9: //TAB key press
if (e.preventDefault){
e.preventDefault();
}
return false;

Eugen_
18 Feb 2010, 9:16 AM
Hi prasanthsd,

try this:



new Ext.form.ComboBox({
...
listeners: {
specialkey: function(field, e) {
if (e.getKey() == e.TAB) {
e.stopEvent();
}
}
}
...
});

prasanthsd
18 Feb 2010, 10:30 AM
hi Eugen_,

Thanks for helping out. But that didnt work. :(

EDIT:
Actually thank you so much. It worked. I added "return false" to it and work fine. Maybe cos I was testing in mozilla

Eugen_
18 Feb 2010, 9:46 PM
EDIT:
It worked. I added "return false" to it and work fine. Maybe cos I was testing in mozilla
It's weird, but it works for me without "return false" (Mozilla FF 3.6, ExtJS 3.1.1)

prasanthsd
19 Feb 2010, 3:37 PM
Well dunno.

One more issue is there with combo. I allow keystrokes only when focus is there in text fields and in combo. on ENTER keypress im making a ajax call to populate a grid. Just before the AJAX call I call combo.blur(). But it dosent actually blur it correctly. The cursor dissapears from the combo tho.

If focus is on some other textfield before AJAX then bluring that field works ok, my key navigation works correctly. But when combo is focused then the blur dosent work. I can see in firebug the focus css class is still there. Because of this the keynavigation get messedup. Please help