Re: Uneditable NSTableView
Re: Uneditable NSTableView
- Subject: Re: Uneditable NSTableView
- From: "Ewan Delanoy" <email@hidden>
- Date: Wed, 23 Apr 2008 16:41:46 +0200 (CEST)
- Importance: Normal
>Perhaps you have a good reason, but from your description, and being
>used to using Mail, I'd expect the lower part to display the content
>with a single click.
The reason is, I know how to produce easily the "double-click" behaviour
with Cocoa but not the (better) "click" behaviour
>Good question -- if you want the double action to be called, you have
>to set the app controller to be the table view's target, not just its
>delegate. You can, of course, make the connection in IB; you don't
>have to use setTarget:.
I'm not quite sure what you mean by "target" here, so I'll be
more specific about how I make my connections :
-since my Cocoa project is relatively simple the app controller's job,
instead of being treated by a separate class, is done directly by a
NSDocument subclass called MyDocument.
-The MyDocument instance acts as a "data source" for the
UneditableTableView, (I tell that to IB as you say by making
the "data source" connection with the mouse. I can see that
this has been done correctly at runtime anyway because the
table view's contents are what they should be). Also,
MyDocument implements
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;
it does not implement
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndexnotnot
because it does need to : the rows are uneditable.
Lastly, as in this case the UneditableTableView's delegate does very
little (I only need
to write the - (BOOL)tableView:(NSTableView *)aTableView
shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
method) I indulged in making a new
class called UneditableTableViewDelegate, (which I also instantiate in IB
and I make the
"delegate" connection in IB also) just for the pleasure of having a very
short
UneditableTableViewDelegate.m file (I was told that it is a better
programming philosophy
to make many short code files that few long ones, but perhaps Cocoa
experts will tell me it is not a good thing to do in this case?)
Ewan
_______________________________________________
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