Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  • The first cellview is a group cell (header cell) and when expand-collapse the textfield for this cellview moves up-down. Only happens with the first one.

  • The textfield in the header cells changes it size (when changes the size in the system preferences) but I would like that the header cells size stay fixed like (Lion) Finder, Mail... does.

  • The string value of the textfield in the header cells doesn´t appear uppercase.

  • The images I use as icon in the image view of the data cells appears transparent (with a 0.5 alpha value or something like that).

Any help? Thanks in advance

SOLVED:

  • For the movement when the first cellview expand/collapse use the method setFloatsGroupRows:NO with the outlineview (Thanks Anton!)

  • If you want fixed size for the font of the groupcells (even if user change it in the system preferences) unbind in IB the header cell with its Table Cell View.

  • Using a valueTransformer (that transform a string to uppercase) with the header cell the string will appear uppercase. Also you can do this with the nsoutlineview datasource method - outlineView:objectValueForTableColumn:byItem:...

  • And finally the icon is semi-transparent because is not enabled. Uncheck "Conditionally Sets Enabled" in the Value or Value Path (depending the one you use) in the image cell bindings

like image 431
Azpiri Avatar asked Jul 25 '11 10:07

Azpiri


2 Answers

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

like image 73
Anton Ivanov Avatar answered Oct 15 '22 00:10

Anton Ivanov


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
like image 23
jeff-h Avatar answered Oct 15 '22 02:10

jeff-h