PDA

View Full Version : blur event and focus issues



k.janiszewski
27 Aug 2012, 1:14 AM
Hi!

I'm using FieldTip plugin to show tips while editing form fields:



FieldTip = function(txt) {
return {
init: function(field){
field.on({
focus: function(){
if(!this.tip){
var tipCfg = {
autoHide: false,
anchor: this.qanchor
};
if (Ext.isString(this.qtip)) {
tipCfg.html = this.qtip;
} else {
tipCfg.html = this.qtip.text;
Ext.apply(tipCfg, this.qtip);
}
this.tip = new Ext.ToolTip(tipCfg);
this.tip.target = this.tip.anchorTarget = this.el;
}
if(!this.qshowfn) {
this.tip.show();
} else {
this.qshowfn();
}
},
blur: function(){
if(this.tip){
if(!this.qblurhidefn) {
this.tip.hide();
} else {
this.qblurhidefn();
}
this.tip.hide();
}
},
destroy: function(){
if(this.tip){
this.tip.destroy();
delete this.tip;
}
}
});
}
}
};

field1 = Ext.create('Ux.filtry.pola.Pelnotekstowe', {
name: 'imie',
fieldLabel: 'Imie',
qtip: 'Testowy komunikat',
plugins: [new FieldTip()]
});

field2 = Ext.create('Ux.filtry.pola.Pelnotekstowe', {
name: 'nazwisko',
qtip: 'Testowy komunikat2',
fieldLabel: 'Nazwisko',
plugins: [new FieldTip()]
});






Tooltips are shown correctly, but when I click on next text field or press TAB to move to next field, tooltip disapears (correctly), but focus is lost. No field has focus. What am I doing wrong?

Best regards
Krzychu

k.janiszewski
27 Aug 2012, 11:48 PM
I've managed to solve this problem. I had to call tip.destroy() instead of tip.hide() in blur event.

I know it is only a workaround and quite ugly, but nothing else works for me.

Best regards
Krzychu

Jangla
10 Apr 2013, 11:18 AM
I've just found this problem too - thanks for posting your solution.

Basically the bug happens because the specialkey event also calls blur so the blur event gets called twice - once on the field you're leaving and once on the field you've tabbed to, which removes focus.

I'll try find a better override...