Azpiri
Azpiri

Reputation: 764

Strange behavior using view-based NSOutline (Sourcelist)

I have a (new in Lion) view-based NSOutlineView as Sidebar SourceList in my app using CoreData + NSTreeController + Bindings + NSOutlineView and an Object as NSOutlineViewDelegate.

I use these delegate methods in the outlineview delegate:

- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item In my case a item is group when the (Core Data) parent relationship is nil.

- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item To return the headercell view (group) or datacell view (icon + text).

And I set the size style of the outline view (in Interface Builder in XCode) as "Sidebar System Default" so the cellview changes its size when the user change it in the system preferences.

It works fine... but there are a few issues:

enter image description here

Any help? Thanks in advance

SOLVED:

Upvotes: 18

Views: 4497

Answers (4)

jeff-h
jeff-h

Reputation: 2624

In case it's not obvious to anyone:

"Floats group rows" in Interface Builder:

You can set "Floats group rows" directly in Interface Builder.

  1. select your Source List in Interface Builder's document outline.

  2. show the Attributes Inspector, and you will find the "Floats Group Rows" checkbox. Untick it, and your nasty jumping group headings suddenly behave themselves :)

In Swift:

Alternatively, if you're in Swift, you can do something like:

@IBOutlet weak var sourceList: NSOutlineView!    
sourceList.floatsGroupRows = false

Upvotes: 3

Besi
Besi

Reputation: 22939

I was wondering how you achieved the source list that's visible on the screenshot.

I have created a little sample project, which does the same and includes the feedback from @anton-ivanov:

  • Display a list of items
  • Edit the items in a master-detail fashion
  • Remove and add items
  • Usage of bindings

Check out besi/mac-quickies on github. Most of the stuff is either done in IB or can be found in the AppDelegate

screenshot

Upvotes: 0

onekiloparsec
onekiloparsec

Reputation: 2063

You may also have a look at the answer of this question: NSOulineView header cell font The automatic style unselect-reselect dance worked for me.

Upvotes: 0

Anton Ivanov
Anton Ivanov

Reputation: 226

Setting setFloatsGroupRows:NO for the outline view must solve the issue with first group item moving up-down when being expanded/collapsed.

Upvotes: 21

Related Questions