Hi everybody,
I am stuck with a (maybe trivial) problem, but I did not find a solution suitable for my case in the old messages and on the net. My situation is this: I want to use a custom button cell inside an OutlineView to add some color and text to the basic checkbox and draw a set of Node objects. I would like to use a treecontroller to manage my Nodes array and use a binding to link the cell value to a Node property containing data like: color, enabled value, title string, title string color, etc...

Trying to understand what to do I implemented this:

I subclassed NSButtonCell (MyCustomCell) and redefined setRepresentedObject: and setObjectValue:

I created in IB an NSOutlineView, dragged in a NSButtonCell and set the cell class to MyCustomCell. I set OutlineView delegate to MyDocument and implemented in MyDocument outlineView:willDisplayCell:forTableColumn:item:

I created a Node class with methods isLeaf: children: childrenCount: and some custom properties (KVC compliant) like nodeName(NSString) nodeColor(NSColor), nodeEnabled(bool).

I filled with some Node a NSMutableArray inside MyDocument and binded it to a NSTreeController ContentArray via IB

Then I binded the tablecolumn Value to the TreeController using the key "nodeEnabled". All worked fine and the normal button cells were drawn correctly.

Then I tried to bind to the column the key "nodeColor". My idea is to intercept the NSColor as it is set inside the cell and use it to do some drawing.

The problem is that:
in MyCustomCell setRepresentedObject: is called only once with object nil (not the displayed Node) setObjectValue is called multiple times (once per visible cell) but object value is always nil (not the color) outlineView:willDisplayCell:forTableColumn:item: is called multiple times but cell seems not a MyCustomCell instance but a simple NSButtonCell. Calling [item representedObject] seems to return a valid ptr to the displayed node, BUT after exiting the method I get an assertion "Cannot create BOOL from object NSCalibratedRGBColorSpace 1 1 1 1 of class NSCachedRGBColor" and the OutlineView is not displayed at all. I surely miss some basic understanding of cells/tables and some methods implementation... :-(

How can I bind correctly a Node property (or a dictionary containing more properties) to my custom cell inside the Outline view so that I can use the properties to do some drawing/coloring? Is it possible using bindings or I am totally out of the right path?

Sorry if I am not so clear but I am a total Cocoa newby.

Thanks in advance for any help or any pointer to interesting documents...

Paull
_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to