• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOutlineView reloadItem:reloadChildren: selection bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView reloadItem:reloadChildren: selection bug


  • Subject: Re: NSOutlineView reloadItem:reloadChildren: selection bug
  • From: Kevin Ballard <email@hidden>
  • Date: Thu, 15 Apr 2004 07:58:18 -0400

NSOutlineView normally deals with the selection just fine. When I have something else selected and I Remove an item above it, the selection stays with the same object just fine (i.e. the same row is selected even though the row index is now different). It only acts odd when the selected item is the last one.

And setting the selection myself won't work because it will select row 1 then the old row again, but each time I change the selection the entire window changes its content view, so the view will be changed twice when it shouldn't be changed at all.

On Apr 15, 2004, at 6:54 AM, Marc LAFFITTE wrote:

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?

--
Kevin Ballard
email@hidden
http://www.tildesoft.com
http://kevin.sb.org
_______________________________________________
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.


References: 
 >Re: NSOutlineView reloadItem:reloadChildren: selection bug (From: Marc LAFFITTE <email@hidden>)

  • Prev by Date: Re: NSArrayController
  • Next by Date: NSController article at O'Reilly
  • Previous by thread: Re: NSOutlineView reloadItem:reloadChildren: selection bug
  • Next by thread: Re: NSOutlineView reloadItem:reloadChildren: selection bug
  • Index(es):
    • Date
    • Thread