Re: connecting a NSButtonCell in an outline view
Re: connecting a NSButtonCell in an outline view
- Subject: Re: connecting a NSButtonCell in an outline view
- From: Phil Frost <email@hidden>
- Date: Mon, 19 Dec 2005 15:12:01 -0500
On Mon, Dec 19, 2005 at 09:40:27AM -0800, David Alter wrote:
>
I have dynamically created and NSButtonCell in side an outline view.
>
But I'm not sure how to get it to respond to clicks. When clicked I
>
want it to call a method in my outline view controller. This would be
>
the equivalent it I where to connect it within Interface Builder.
>
Could someone please point me to what I need to be doing next.
>
>
Here is what I have done to create the NSButtonCell
>
>
- (void)awakeFromNib
>
{
>
[outlineView setOutlineTableColumn:[ outlineView
>
tableColumnWithIdentifier:@"title"]]; // Move the outline view column
>
over by one.
>
>
NSTableColumn * cbCol = [ outlineView
>
tableColumnWithIdentifier:@"enable"];
>
NSButtonCell * checkbox = [NSButtonCell new];
>
[checkbox setButtonType:NSSwitchButton];
>
[checkbox setTitle:@""];
>
[checkbox setImagePosition:NSImageOnly];
>
[cbCol setDataCell:checkbox];
>
>
}
See the documentation for these methods in your favorite AppKit
reference:
-[NSActionCell setTarget:]
-[NSActionCell setAction:]
-[NSTableView clickedRow]
Also, from your example, it looks like you could create the cell in IB.
In the Cocoa-Data palette, NSButtonCell looks like a checkbox with
horizontal lines above and below. Drag it on to a column to use it. In
the header of that column, you will see a triangle on the right; this is
the NSButtonCell. You can then set its attributes in the inspector, and
ctrl-drag from it to set the target and action. You will still need
-[NSTableView clickedRow], since there is only one cell per column.
_______________________________________________
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