-
15 May 2007 7:28 AM #1
Tab is activated when close button clicked
Tab is activated when close button clicked
See Tabs Example 2.
When you close tab that is not the active one, it will be activated before its closed.
stopEvent() should prevent the tab from receiving the click event. but somehow this doesnt work I think.
PHP Code:/** @private */
closeClick : function(e){
var o = {};
e.stopEvent();
this.fireEvent("beforeclose", this, o);
if(o.cancel !== true){
this.tabPanel.removeTab(this.id);
}
}
-
15 May 2007 7:36 AM #2
I don't see this behavior. The click event for the close icon would fire first (even if it bubbles) and it removes the tab.
-
15 May 2007 7:40 AM #3
Hm I really do, try holding your mouse button for a sec when clicking the close button.
-
15 May 2007 8:56 AM #4
yeah tried holding the mouse button and it does what u say.
however.... if you press and hold down your mouse button, is it still considered a click?
-
15 May 2007 11:56 PM #5
Ahah! That would be a mousedown which goes through this code:
Perhaps that could check the target, and only activate if the original target was not the close button.Code:onTabMouseDown : function(e){ e.preventDefault(); this.tabPanel.activate(this.id); },
-
16 May 2007 1:55 AM #6
-
16 May 2007 3:06 AM #7
Try adding this code after including ext-all.js:
Code:Ext.override(Ext.TabPanelItem, { onTabMouseDown : function(e){ e.preventDefault(); if (!e.getTarget().hasClass("close-icon")) { this.tabPanel.activate(this.id); } } });
-
16 May 2007 4:12 AM #8
Error: e.getTarget().hasClass is not a function
Still works since the tab is activated onclick. but no longer on mousedown.
Maybe you mean getTarget(false, false, true) (return a Ext.Element object instead of DOM node).
But... this doesnt seem to work eather, I guess this is due to another bug in EventObject: It never returns a Ext.Element
shoulnt this be something likePHP Code:getTarget : function(selector, maxDepth, returnEl){
return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : this.target;
}
PHP Code:Ext.override(Ext.EventObject, {
getTarget : function(selector, maxDepth, returnEl){
if(selector) {
return Ext.fly(this.target).findParent(selector, maxDepth, returnEl);
}
else {
return returnEl ? Ext.get(this.target) : this.target;
}
}
});
-
16 May 2007 4:23 AM #9
This works:
Code:Ext.override(Ext.TabPanelItem, { onTabMouseDown : function(e){ e.preventDefault(); var t = Ext.get(e.getTarget()); if (!t.hasClass("close-icon")) { this.tabPanel.activate(this.id); } } });
-
16 May 2007 4:38 AM #10
It does thank you.
But isnt the other thing a bug as well?


Reply With Quote