Re: NSButtonCell visibility binding in NSOutlineView [SOLVED]
Re: NSButtonCell visibility binding in NSOutlineView [SOLVED]
- Subject: Re: NSButtonCell visibility binding in NSOutlineView [SOLVED]
- From: Chris Tracewell <email@hidden>
- Date: Wed, 29 Apr 2009 09:31:22 -0700
- Resent-date: Wed, 29 Apr 2009 09:35:20 -0700
- Resent-from: Chris Tracewell <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
Kyle,
Thanks for the reply. Yes I know and agree on the issue of the
usability. I struggled with this but ultimately felt it was essential
as other options disassociated the property from the object too much
or made it appear that a given object could indeed have the property
enabled.
What I made work, and feels like the best solution is to use was a OV
delegate I had missed. It's nice as it requires no custom drawing and
allows me to inspect the object. It took one IBOutlet to bind to the
column I wanted to modify.
-(NSCell *)outlineView:(NSOutlineView *)outlineView
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if (tableColumn == myAttributeColumn && ![[[[item representedObject]
representedObject] myType] isEqualToString:@"style"])
{
return [NSTextFieldCell new];
}
return [tableColumn dataCellForRow:item];
}
Chris
On Apr 29, 2009, at 12:04 AM, Kyle Sluder wrote:
On Tue, Apr 28, 2009 at 1:12 PM, Chris Tracewell <email@hidden>
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.
Hm. I'm conflicted as to whether or not from a usability standpoint
you should prefer to display a disabled cell or none at all.
NSTableView has a -tableView:dataCellForTableColumn:row: delegate
method, so you don't need to subclass NSTableColumn. Perhaps the
better approach is to subclass NSButtonCell and implement
-drawWithFrame:inView: somewhat like this:
-(void)drawWithFrame:(NSRect)frame inView:(NSView *)view {
if([self shouldDisplayCheckboxForObject:[self objectValue]])
[super drawWithFrame:frame inView:view];
}
Then, of course, you need to implement
-shouldDisplayCheckboxForObject, set an instance of this cell as the
cell for your table column, and bind the column to your model objects
instead of an attribute thereof.
--Kyle Sluder
_______________________________________________
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