Created
December 23, 2011 04:03
-
-
Save danwood/1513093 to your computer and use it in GitHub Desktop.
Scroll the the bottom if you are at the bottom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) scrollToVisible:(id)unused | |
{ | |
// Only show bottom if we are already scrolled down at/near the bottom. | |
NSScrollView *scrollView = [oLog enclosingScrollView]; | |
NSPoint currentScrollPosition=[[scrollView contentView] bounds].origin; | |
float diff = oLog.frame.size.height - (scrollView.contentSize.height + currentScrollPosition.y); | |
if (diff < 50) // Seems like it's often 39 when we're at the bottom, so give some slack. | |
{ | |
// [oLog scrollRangeToVisible:NSMakeRange([[oLog textStorage] length], 0)]; | |
// Below might be better: | |
[scrollView.contentView scrollToPoint:NSMakePoint(0, oLog.frame.size.height - scrollView.contentSize.height)]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment