Re: NSButtonCell visibility binding in NSOutlineView
Re: NSButtonCell visibility binding in NSOutlineView
- Subject: Re: NSButtonCell visibility binding in NSOutlineView
- From: Ashley Clark <email@hidden>
- Date: Wed, 29 Apr 2009 12:59:12 -0500
On Apr 29, 2009, at 11:46 AM, Chris Tracewell wrote:
On Apr 29, 2009, at 8:13 AM, Ashley Clark wrote:
On Apr 28, 2009, at 12:12 PM, Chris Tracewell wrote:
I am looking for the best method of turning off the visibility of
an NSButtonCell object for individual rows in an OutlineView/
TableView. I have an OutlineView that is bound to a
TreeController. There are two columns. In the last column I am
using a checkbox cell that should only be visible to the user when
a representedObject in the TreeController has a certain property
value. There is no Visibility binding only Enabled which does not
hide the control but just dims it.
I am using bindings to return a custom image for setImage and
setAlternateImage to display a custom NSImage instead of the
regular checkbox. It works nicely. I tried using conditional logic
to return a transparent image when I want to hide the control but
that affects the entire column. If I need to subclass I am
suspecting I need to override NSTableColumn's dataCellForRow, but
then how do I obtain the representedObject for that row?
Why not just implement -
outlineView:willDisplayCell:forTableColumn:item: on your delegate
and then set your images there depending on what item is about to
be displayed?
I tried that by setting the image but I need 3 states for the
checkbox - OFF, ON, HIDDEN. Whenever I set a certain row to a HIDDEN
image to hide that row it would affect the image for all other items
too. So it looked like I would need to subclass, however I found the
solution and just posted about it before your email came in...
-(NSCell *)outlineView:(NSOutlineView *)outlineView
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
When using willDisplayCell you have to set the image for all rows to
whatever the image should be for that row.
Something along the lines of:
if (rowShouldBeHidden) {
[cell setImage:nil];
[cell setAlternateImage:nil];
}
else {
[cell setImage:normalImage];
[cell setAlternateImage:alternateImage];
}
Ashley
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden