X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/src/widgets/tree/TreeSelectionModel.js diff --git a/src/widgets/tree/TreeSelectionModel.js b/src/widgets/tree/TreeSelectionModel.js index 736d5eb8..d0f0c085 100644 --- a/src/widgets/tree/TreeSelectionModel.js +++ b/src/widgets/tree/TreeSelectionModel.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -38,7 +38,7 @@ Ext.tree.DefaultSelectionModel = function(config){ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { init : function(tree){ this.tree = tree; - tree.getTreeEl().on("keydown", this.onKeyDown, this); + tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this); tree.on("click", this.onNodeClick, this); }, @@ -51,7 +51,11 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * @param {TreeNode} node The node to select * @return {TreeNode} The selected node */ - select : function(node){ + select : function(node, /* private*/ selectNextNode){ + // If node is hidden, select the next node in whatever direction was being moved in. + if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) { + return selectNextNode.call(this, node); + } var last = this.selNode; if(node == last){ node.ui.onSelectedChange(true); @@ -110,24 +114,24 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * Selects the node above the selected node in the tree, intelligently walking the nodes * @return TreeNode The new selection */ - selectPrevious : function(){ - var s = this.selNode || this.lastSelNode; - if(!s){ + selectPrevious : function(/* private */ s){ + if(!(s = s || this.selNode || this.lastSelNode)){ return null; } + // Here we pass in the current function to select to indicate the direction we're moving var ps = s.previousSibling; if(ps){ if(!ps.isExpanded() || ps.childNodes.length < 1){ - return this.select(ps); + return this.select(ps, this.selectPrevious); } else{ var lc = ps.lastChild; - while(lc && lc.isExpanded() && lc.childNodes.length > 0){ + while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){ lc = lc.lastChild; } - return this.select(lc); + return this.select(lc, this.selectPrevious); } } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){ - return this.select(s.parentNode); + return this.select(s.parentNode, this.selectPrevious); } return null; }, @@ -136,20 +140,20 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * Selects the node above the selected node in the tree, intelligently walking the nodes * @return TreeNode The new selection */ - selectNext : function(){ - var s = this.selNode || this.lastSelNode; - if(!s){ + selectNext : function(/* private */ s){ + if(!(s = s || this.selNode || this.lastSelNode)){ return null; } - if(s.firstChild && s.isExpanded()){ - return this.select(s.firstChild); + // Here we pass in the current function to select to indicate the direction we're moving + if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){ + return this.select(s.firstChild, this.selectNext); }else if(s.nextSibling){ - return this.select(s.nextSibling); + return this.select(s.nextSibling, this.selectNext); }else if(s.parentNode){ var newS = null; s.parentNode.bubble(function(){ if(this.nextSibling){ - newS = this.getOwnerTree().selModel.select(this.nextSibling); + newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext); return false; } }); @@ -221,7 +225,7 @@ Ext.tree.MultiSelectionModel = function(config){ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, { init : function(tree){ this.tree = tree; - tree.getTreeEl().on("keydown", this.onKeyDown, this); + tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this); tree.on("click", this.onNodeClick, this); },