Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bound NSBrowser always shows horizontal scrollbar



On 24 Jun 2006, at 4:42 pm, Glen Low wrote:

I have bound the content, contentValues and selectionIndexPaths of a NSBrowser to a suitable NSTreeController. Everything works swimmingly, except that although I set it to hide horizontal scrollers, they keep on coming back when I click on various browser items, even when the depth is less than the visible depth of the browser. Any way of permanently inhibiting the horizontal scroller display behavior?

I'm not sure if this answer meets your case, since it's not clear whether you want to suppress the horizontal scrollbar completely or just rectify its autohide behaviour. Assuming the latter, I found the same problem and ended up using the following kludge. (In my case I put this code in -browserColumnConfigurationDidChange:. Alternatively it could be called when the browser selection changes.)


float totalWidth = 0;
int index, lastIndex = [browser lastColumn];
for (index = 0; index <= lastIndex; index++)
totalWidth += [browser frameOfColumn:index].size.width;
/* First check if total column widths are greater than the visible width of the browser */
BOOL showScroller = totalWidth > [browser visibleRect].size.width ? YES : NO;
/* In some cases, the column widths may be less than the visible width but the leftmost column
is still outside the view, therefore still requiring a scrollbar. */
if (!showScroller)
showScroller = [browser frameOfColumn:0].origin.x < 0 ? YES : NO;
[browser setHasHorizontalScroller:showScroller];


It's a bit ugly but it works for me.

Regards,
Jeremy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Bound NSBrowser always shows horizontal scrollbar (From: Glen Low <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.