Skip navigation.
 
mlRe: Source list group item indentation
FROM : Ben
DATE : Wed Jan 16 19:55:22 2008

On 16 Jan 2008, at 18:08, Corbin Dunn wrote:

>
> On Jan 16, 2008, at 2:23 AM, Kyle Sluder wrote:
>

>> (Sorry if you're getting this twice, I'm an idiot and forgot to set
>> the From option.)
>>
>> On Jan 15, 2008 6:15 PM, Corbin Dunn <<email_removed>> wrote:

>>> I realize the release notes are rather long, but they are a good 
>>> read.
>>> Especially for controls/components that you use.

>>
>> I did read them, but obviously not closely enough.  ;)
>>
>> To be honest, this seems like The Wrong Way(tm) to do it.  It seems
>> far more appropriate for the delegate to provide this information, 
>> and
>> thus suffer from the tight coupling with the data source.  Filed as 
>> r.
>> 5690092.

>
> Thank you for logging the bug! This is the best way to get things 
> like this changed.
>
> For others, Kyle is basically asking that the option to show a 
> disclosure triangle be determined by a delegate method. That is an 
> excellent it, and it is something we have wanted to do. It was more 
> of a timing issue for why it wasn't done.
>
> thanks,
> corbin
>


I'm a little unsure of the netiquette here, as I have a nice solution 
BUT *it is someone else's code* and I don't know who/where from! 
Explanation follows, but please don't credit me for it.

Subclass NSOutlineView, and override the following method:

- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row
{
   // Default to show triangle
   BOOL showTriangle = YES;
   
   // See if delegate responds to new selector
   if ([[self delegate] 
respondsToSelector
:@selector(outlineView:shouldShowDisclosureTriangleForItem:)])
   {
       // Perform selector using objc_msgSend() to avoid compiler warnings
       SEL selector = 
@selector(outlineView:shouldShowDisclosureTriangleForItem:);
       id item = [self itemAtRow:row];
       
       showTriangle = (objc_msgSend([self delegate], selector, self, item) !
= 0x00);
   }
   
   if (!showTriangle)
   {
       // If not showing triangle, return empty rect
       return NSZeroRect;
   }
   else
   {
       // else return default value
       return [super frameOfOutlineCellAtRow:row];
   }
}


Then, replace your outline views in IB with your custom one, and the 
delegate can implement:

- (void)outlineView:(NSOutlineView *) 
shouldShowDisclosureTriangleForItem:(id)item

to decide whether or not to show the triangle.

--Ben

Related mailsAuthorDate
mlSource list group item indentation Kyle Sluder Jan 11, 15:16
mlRe: Source list group item indentation Jean-Daniel Dupas Jan 11, 15:24
mlRe: Source list group item indentation Jonathan Dann Jan 11, 16:12
mlRe: Source list group item indentation Corbin Dunn Jan 16, 00:15
mlRe: Source list group item indentation Kyle Sluder Jan 16, 11:23
mlRe: Source list group item indentation Corbin Dunn Jan 16, 19:08
mlRe: Source list group item indentation Ben Jan 16, 19:55
mlRe: Source list group item indentation Corbin Dunn Jan 16, 20:49
mlRe: Source list group item indentation Hamish Allan Jan 16, 20:52
mlRe: Source list group item indentation Pete Callaway Jan 17, 09:34