[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

More NSOutlineView bugs

From: Guenther Noack
Subject: More NSOutlineView bugs
Date: Sun, 4 Feb 2007 18:19:24 +0100
User-agent: Mutt/1.5.13 (2006-08-11)


Playing around with outline drag&drop, I found some other
selection-related issues in NSOutlineView:

- Inconsistency

The NSOutlineView method -noteNumberOfRowsChanged forgets about the
case where only one item is allowed to be selected. This leads to
inconsistencies within NSTableView which result in wrongly selected
rows in outline views. It can be fixed by adding this code snippet
before the -setFrame call:

if ([_selectedRows count] == 0) {
  _selectedRow = -1;
} else {
  _selectedRow = [_selectedRows lastIndex];

- More inconsistency

The -reloadData method in NSTableView calls -noteNumberOfRowsChanged,
too. As the -noteNumberOfRowsChanged method restores the selected row
index set _selectedRows (and hopefully the _selectedRow index, too, soon)
from the _selectedItems instance variable, NSOutlineView's -reloadData
has to assign a suitable value to that as well.

To fix the bug, insert this at the beginning of -reloadData (before
_items is set to nil):

// We save the selection
[_selectedItems removeAllObjects];
int row = [_selectedRows firstIndex];
while (row != NSNotFound)
    if ([self itemAtRow: row])
        [_selectedItems addObject: [self itemAtRow: row]];
    row = [_selectedRows indexGreaterThanIndex: row];

BTW: The whole issue also applies to the -reloadItem:reloadChildren:
method. There's even a FIXME describing the problem.

- Documentation

There's also an issue with the -outlineView:acceptDrop:item:childIndex:
and -outlineView:validateDrop:proposedItem:proposedChildIndex: methods.
Their documentation is not correct. As I understood it from the Apple
documentation, the validateDrop method is called by the outline view to
ask its delegate which drag operation type is going to be performed.
The acceptDrop method is then called on the delegate to perform the
actual operation.

Again, sorry that I couldn't prepare patches. I don't use the -SVN
version of GNUstep here, but I verified in the web svn browser that
the bugs have not been fixed yet.

With best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]