No respond from Switch button on NSTableView
No respond from Switch button on NSTableView
- Subject: No respond from Switch button on NSTableView
- From: Peter <email@hidden>
- Date: Mon, 3 Oct 2005 20:53:34 +0800
Hello,
I have been trying to implement a row of checkbox (Switch button)
similar to Apple Mail (Preferences -> Rules NSTableView). While I am
able to get the checkbox to be display on the NSTableView but it does
not respond to clicks (check/uncheck).
1) How do I make the check box respond to user's click ?
2) In long list of items, how do I access one or more of the check box ?
Below is a simple source code showing what I did.
Thanks in Advance.
Peter.
#import "MainController.h"
// NSTableView contains 2 columns consists of identifier @"checkbox"
and @"description"
@implementation MainController
- (void) awakeFromNib
{
NSButtonCell *button;
NSTableColumn *col;
[tabView setDataSource:self];
[tabView setDelegate:self];
button = [[[NSButtonCell alloc] init] autorelease];
[button setButtonType:NSSwitchButton];
[button setImagePosition:NSImageOnly];
col = [tabView tableColumnWithIdentifier:@"checkbox"];
[col setDataCell:button];
}
- (int)numberOfRowsInTableView: (NSTableView *) theTableView
{
return 1;
}
- (id)tableView:(NSTableView *) theTableView
objectValueForTableColumn:(NSTableColumn *)theColumn
row:(int)rowIndex
{
if ([[theColumn identifier] isEqualToString:@"description"])
return @"One only";
return nil;
}
@end
_______________________________________________
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