Index: dojo-release-1.3.2-src/dijit/_KeyNavContainer.js =================================================================== --- dojo-release-1.3.2-src.orig/dijit/_KeyNavContainer.js 2010-03-22 06:58:02.000000000 -0700 +++ dojo-release-1.3.2-src/dijit/_KeyNavContainer.js 2010-03-22 06:58:32.000000000 -0700 @@ -1,6 +1,8 @@ dojo.provide("dijit._KeyNavContainer"); dojo.require("dijit._Container"); +var gcount = 0; + dojo.declare("dijit._KeyNavContainer", [dijit._Container], { @@ -45,6 +47,9 @@ dojo.forEach(nextKeyCodes, function(code){ keyCodes[code] = next; }); this.connect(this.domNode, "onkeypress", "_onContainerKeypress"); this.connect(this.domNode, "onfocus", "_onContainerFocus"); + + this._childNode = []; + this._childNodeConnects = []; }, startupKeyNavChildren: function(){ @@ -62,6 +67,11 @@ this._startupChild(widget); }, + removeChild: function(/*Widget or int*/ widget){ + this._removeChild(widget); + dijit._KeyNavContainer.superclass.removeChild.apply(this, arguments); + }, + focus: function(){ // summary: // Default focus() implementation: focus the first child. @@ -133,6 +143,17 @@ } }, + _removeChild: function(/*Widget*/ widget) { + if(widget.getFocalNodes){ + dojo.forEach(widget.getFocalNodes(), function(node){ + this._disconnectNode(node); + }, this); + }else{ + var node = widget.focusNode || widget.domNode; + var connects = this._disconnectNode(node); + } + }, + _startupChild: function(/*Widget*/ widget){ // summary: // Set tabindex="-1" on focusable widgets so that we @@ -143,24 +164,44 @@ if(widget.getFocalNodes){ dojo.forEach(widget.getFocalNodes(), function(node){ dojo.attr(node, "tabindex", -1); - this._connectNode(node); + var connects = this._connectNode(node); + this._childNode.push(node); + this._childNodeConnects.push(connects); }, this); }else{ var node = widget.focusNode || widget.domNode; if(widget.isFocusable()){ dojo.attr(node, "tabindex", -1); } - this._connectNode(node); + var connects = this._connectNode(node); + this._childNode.push(node); + this._childNodeConnects.push(connects); } }, + _disconnectNode: function(node) { + dojo.some(this._childNode, function(n, i) { + if (n == node) { + dojo.forEach(this._childNodeConnects[i], function(c) { + this.disconnect(c); + }, this); + this._childNode.splice(i, 1); + this._childNodeConnects.splice(i, 1); + return true; + } + return false; + }, this); + }, + _connectNode: function(/*Element*/ node){ // summary: // Monitor focus and blur events on the node // tags: // private - this.connect(node, "onfocus", "_onNodeFocus"); - this.connect(node, "onblur", "_onNodeBlur"); + var connects = []; + connects.push(this.connect(node, "onfocus", "_onNodeFocus")); + connects.push(this.connect(node, "onblur", "_onNodeBlur")); + return connects; }, _onContainerFocus: function(evt){