Re: NSTableView using Square Button for image
Re: NSTableView using Square Button for image
- Subject: Re: NSTableView using Square Button for image
- From: Andrew Merenbach <email@hidden>
- Date: Sat, 9 Sep 2006 19:23:36 -0700
Hi, Kevin. I would use an NSImageCell as the data cell for the image
column of your table view. Since you want it to display only when a
particular value is true, you can set it to use a binding with an
NSValueTransformer that checks whether the input (which will be an
NSNumber) has a boolValue of YES, and then (if it does) you can
return your image. Thus:
1. Set your table column, in Interface Builder, to have a data cell
type of NSImageCell.
2. Bind the "value" of the table column to the boolean value of your
data source.
3. Set the "value" binding's value transformer in Interface Builder
to the name of an instance of the following:
@implementation KHArrowIconValueTransformer
- (id)init {
if (self = [super init]) {
arrowImage = [[NSImage imageNamed:@"ArrowIcon"] retain];
}
return self;
}
- (void)dealloc {
[arrowImage release];
arrowImage = nil;
[super dealloc];
}
+ (Class)transformedValueClass { return [NSImage class]; }
+ (BOOL)allowsReverseTransformation { return NO; }
- (id)transformedValue:(id)value {
return ([value boolValue] ? arrowImage : nil);
}
@end
Hope this helps!
Cheers,
Andrew
On 9 Sep 2006, at 15:17, Kevin Hoctor wrote:
I'm using a square button in an NSTableView column to display an
arrow image when the data source has a true value in the related
field. The problem is that the user can still toggle the value
(turning off the arrow I'm putting in there programmatically) even
though I have the Editable flag turned off in that column. I can
disable it, but then it dims out my graphic.
I'm not married to this method so I'll take any other solutions.
All I want to do is show a graphic when a value in a cell is true
but keep it read only. TIA!
Peace,
Kevin Hoctor
No Thirst Software
http://nothirst.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40ucla.edu
This email sent to email@hidden
_______________________________________________
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