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:
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
Setting setFloatsGroupRows:NO for the outline view must solve the issue with first group item moving up-down when being expanded/collapsed.
In case it's not obvious to anyone:
You can set "Floats group rows" directly in Interface Builder.
select your Source List in Interface Builder's document outline.
show the Attributes Inspector, and you will find the "Floats Group Rows" checkbox. Untick it, and your nasty jumping group headings suddenly behave themselves :)
Alternatively, if you're in Swift, you can do something like:
@IBOutlet weak var sourceList: NSOutlineView!
sourceList.floatsGroupRows = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With