Reputation: 31
I'm putting a WebView in an NSPanel and would like it to use small scroll bars. How do I tell it to? (Can't be done in Interface Builder)
I realize a WebView has a number of different types of subviews, depending on the content that's loaded. But suppose I'm loading a web page with no frames. What view would contain the main vertical scroll bar? Is there an NSScrollView somewhere or is this managed differently?
Upvotes: 1
Views: 1183
Reputation: 46020
Once a document has loaded into a frame you can access the NSView
for the document and then access its enclosing scroll view, allowing you to set the scrollers to the size you want:
- (void)loadWebView
{
webView.frameLoadDelegate = self;
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://daringfireball.net"]]];
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
//get the scroll view that contains the frame contents
NSScrollView* scrollView = [[[[webView mainFrame] frameView] documentView] enclosingScrollView];
[[scrollView verticalScroller] setControlSize: NSSmallControlSize];
[[scrollView horizontalScroller] setControlSize: NSSmallControlSize];
}
Upvotes: 3