Re: NSTableColumn not usable with binder of class NSTextValueBinder?
Re: NSTableColumn not usable with binder of class NSTextValueBinder?
- Subject: Re: NSTableColumn not usable with binder of class NSTextValueBinder?
- From: Dave Dribin <email@hidden>
- Date: Thu, 21 Aug 2008 00:33:05 -0500
On Aug 20, 2008, at 3:35 AM, Ken Ferry wrote:
FYI, you should avoid using direct subclasses of NSCell in controls on
Leopard and previous.
Well, that settles that, then. ;)
It's somewhat unfortunate, but there are many cases where messages
need to flow from a cell up to a view. If your cell isn't an action
cell, that message flow won't work. It's usually fine as long as your
cell is purely stamped out drawing. If your cell has more complicated
interactions with the user, like use of a field editor or rollovers or
what have you, you're liable to see problems with non-action cells.
This cell is just drawing, but given the bindings issue and the advice
above, it looks like staying away from NSCell is a good idea, ATM.
I suspect the problem here is that NSCell and NSActionCell don't have
a value binding! Check the Cocoa bindings reference.
Well, the Cocoa bindings reference does not have an entry for either
NSCell or NSActionCell. For the next best thing, I printed out the
return value of -exposedBindings for both. For NSCell, we've got
these bindings:
Exposed bindings: (
editable,
enabled,
font,
fontBold,
fontFamilyName,
fontItalic,
fontName,
fontSize
)
And for NSActionCell, we've got these:
Exposed bindings: (
editable,
enabled,
font,
fontBold,
fontFamilyName,
fontItalic,
fontName,
fontSize,
value
)
Indeed, NSActionCell has a "value" binding while NSCell does not.
The information about how the bindings need to be hooked up may be
determined at design time in IB. If IB thinks you have a text cell,
you might get a binding set up in a way appropriate for a text cell.
In any case, this 'binder' thing should have a bug too, if you please.
The NSTextValueBinder error message is a bug? Or the fact that NSCell
does not have a "value" binding? Or both? ;)
If you want to go the bindings route, you could implement a value
binding on your cell subclass by overriding -bind:toObject:
withKeyPath:options: and then bind at runtime. That'd probably do the
trick.
I tried this, and it does not work. In fact -
bind:toObject:withKeyPath:options: never gets called in my NSCell
subclass. I even called [self exposeBinding:@"value"] in +initialize,
and bind:toObject:... still does not get called. Is this a different
bug? It seems like I should be able to add bindings to an NSCell
subclass in this way.
In any case, I'm back to subclassing NSActionCell as the way to get
this working.
-Dave
_______________________________________________
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