Re: NSOutlineView reloadItem:reloadChildren: selection bug
Re: NSOutlineView reloadItem:reloadChildren: selection bug
- Subject: Re: NSOutlineView reloadItem:reloadChildren: selection bug
- From: Marc LAFFITTE <email@hidden>
- Date: Thu, 15 Apr 2004 12:55:19 +0200
Hello,
It looks like that NSTableView, hence NSOutlineView, does handle
selections only through row indexes. (All selection methods deal with
indexes).
Hence, if you insert or remove an item from the view, then the index of
the selected item will change if the index of the added or removed item
is lower than the one of the selected row.
If you reload the view, then... it's reloaded: it forgets its previous
content and selection. Therefore the first one is selected by default
if you does not allow empty selections.
Hence, you should remember the index of the currently selected item via
selectedRow, remove or add your item, reload the view and reselect the
item via selectRow:byExtendingSelection: while using your saved index
eventually plus or minus one...
Any better idea?
Marc
On jeudi, avr 15, 2004, at 12:02 Europe/Paris, Kevin Ballard wrote:
Is this a bug in Cocoa or have I just not found it in my code yet? I
have an NSOutlineView and it changes fairly regularly, so when it does
I call reloadItem:reloadChildren:. The outline view is also set to not
allow an empty selection. This works fine most of them time, but if I
remove an item from the tree and reload the outline view while I
currently have the *last* item in the view selected, it moves my
selection to the *first* item! If I turn on allowsEmptySelection right
before the reload, it simply gets rid of my selection entirely. Why is
it removing my selection? It tracks the selection during reloads just
fine if I have anything else selected, so why is it screwing up if I
have the last item selected? And is there any way around this bug? And
I can't very well simply re-set the selection back to the item after
the reload, because when the selection changes I change the view of the
entire window and I don't want the window to flicker because I'm
changing the view twice really quickly.
--
Kevin Ballard
email@hidden
http://www.tildesoft.com
http://kevin.sb.org
[demime 0.98b removed an attachment of type
application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.