Skip to content

Commit

Permalink
Only modify focus if all previously selected nodes have been removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Harvey committed Dec 18, 2011
1 parent 2e74e3f commit 1dfef66
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions SharpTreeView/SharpTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1dfef66

Please sign in to comment.