Browse files

Only modify focus if all previously selected nodes have been removed.

  • Loading branch information...
1 parent 2e74e3f commit 1dfef669122aab402b5360bfdcd4124535a04e39 @EdHarvey EdHarvey committed Dec 18, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 SharpTreeView/SharpTreeView.cs
View
10 SharpTreeView/SharpTreeView.cs
@@ -151,11 +151,13 @@ void flattener_CollectionChanged(object sender, NotifyCollectionChangedEventArgs
if (selectedOldItems != null) {
var list = SelectedItems.Cast<SharpTreeNode>().Except(selectedOldItems).ToList();
SetSelectedItems(list);
+ if (SelectedItem == null) {
+ // if we removed all selected nodes, then move the focus to the node
+ // preceding the first of the old selected nodes
+ SelectedIndex = Math.Max(0, e.OldStartingIndex - 1);
+ FocusNode((SharpTreeNode)SelectedItem);
+ }
}
- // reset the focus to the previous node
- SelectedIndex = Math.Max(0, e.OldStartingIndex - 1);
- if (SelectedItem != null)
- FocusNode((SharpTreeNode)SelectedItem);
}
}

0 comments on commit 1dfef66

Please sign in to comment.