Re: Disallow edit for rows in NSOutlineView
Re: Disallow edit for rows in NSOutlineView
- Subject: Re: Disallow edit for rows in NSOutlineView
- From: James Bucanek <email@hidden>
- Date: Thu, 15 Jun 2006 11:05:01 -0700
Fredrik Olsson wrote on Thursday, June 15, 2006:
>James Bucanek skrev:
>> Fredrik Olsson wrote on Thursday, June 15, 2006:
>>
>>
>>> I can disallow drag and drop, and selection of rows in an outline view,
>>> but how can I disallow the user to edit some rows?
>>>
>>> A logiclal delegate method would be
>>> -outlineView:shouldBeginEditingItem:forTableColumn:
>>> But I can not find anything resembling that in the documentation, nor
>>> google :/.
>>>
>>
>> Sorry about that last post: I was rushing becuase I wanted to get my coffee, and as soon as I had I realized that
>my post was completely wrong.
>>
>> This is the delegate method you're looking for:
>>
>> - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
>>
>>
>Thanks allot!
>
>Is there a list for what methods from NSTableView NSOutlineView uses and
>what methods are irrelevant? As many methods looks to be replaced but
>with outlineView... instead of tableView... in the name.
It's pretty straight forward (although not enough that I didn't manage to confuse myself this morning).
You have to pay attention to the distinction between member methods and delegate methods. In this case, all of the tableView:... methods are defined in the protocol for NSTableView's delegate. Likewise, all of the outlineView:... methods are defined in the protocol for NSOutlineView's delegate.
This isn't a naming convention so much as matter of practicality. A delegate does not (inherently) have a reference to the table or outline that is using it -- if only for the obvious reason that multiple tables or outlines can be using the same instance of a delegate. All of the messages sent to the delegate must, therefor, include a parameter indicating which table/outline object is being referred to. By convention, this is the first parameter in the message.
Methods defined in the NSTableView and NSOutlineView classes must be sub-classed to be overridden. As member methods, each implicitly knows the object being operated upon and doesn't need that information with a formal parameter.
A subclass inherits all of its super-class' methods, but not those defined for its delegate. A subclass may elect to use or extend the delegate methods defined by its super-class or do something completely different. In the case of NSTableView and NSOutlineView, NSOutlineView inherits all of the methods defined in NSTableView (and NSView, and NSResponder, ...). However, NSOutlineView has elected to use its own protocol for its delegate, sending only outlineView:... methods and suppressing all of the tableView:... delegate methods used by NSTableView.
--
James Bucanek
_______________________________________________
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