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 <ch...@thinkcl.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to