Re: NSTableColumn & binding value
Re: NSTableColumn & binding value
- Subject: Re: NSTableColumn & binding value
- From: Kaspar Fischer <email@hidden>
- Date: Tue, 29 Mar 2005 11:30:20 +0200
On 28.03.2005, at 05:46, mmalcolm crawford wrote:
On Mar 27, 2005, at 7:14 PM, Kaspar Fischer wrote:
For the second column, I want to bind the image of
NSTableColumn's buttons to the image provided by the
model. So I want to do something like binding the
second column to the controller with controll-key
"arrangedObjects" and model-path "image" BUT: this
binding should NOT bind the value of the button
BUT ITS IMAGE. How can I do this?
In what way does what you want to do differ from the example in the
documentation:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Tasks/images.html>
?
In the documentation example, they drop a NSImageView (or
an NSImageCell) onto the column header. In my case I
drop a NSButtonCell onto the column header and now want
to bind the IMAGE of the button. I.e., I drag a check-
box NSButtonCell onto the column header and afterwards
change the button's type to a square-button. Now I want
to bind the button's image. The problem is that when
I change the button's type, the binding options displayed
in the binding inspector in IB for NSTableColumn change,
too, and there is no value anymore to bind to. Apparently,
a button does not have a "value". So my question is: Can
I tell NSTableColumn to not change/use the key "value"
for feeding the table but to use some different key
("image" in my case)?
I guess the answer to the question is "no", right? There-
fore I tried to subclass NSButtonCell and make the button
I dropped onto the header an instance of the class. I
thought, all I have to do is to intercept "setObjectValue"
and set the image there:
@interface ButtonCellWithImageAsValue : NSButtonCell
{
NSImage *_currentImg;
}
@end
#import "ButtonCellWithImageAsValue.h"
@implementation ButtonCellWithImageAsValue
- (void)setObjectValue:(id)object
{
NSLog(@"setObjectValue %@",object);
[self setImage:object];
_currentImg = object;
}
- (id)objectValue
{
NSLog(@"objectValue");
return _currentImg;
}
@end
But this does not work: setObjectValue is called once
with object==nil and then an exception "Cannot create BOOL
from object NSImage" gets thrown.
Any idea's how to solve this?
Thanks,
Kaspar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden