简体   繁体   中英

How do I increase the width of an NSScroller in a WebView

I am developing a web browser for a touch-screen kiosk and the scrollbars on the WebView are impractically small for being able to scroll using them on a touch-screen. Is there anyway to increase the size of them?

I can get a reference to the vertical scroller using

[[[[[webView mainFrame] frameView] documentView] enclosingScrollView] verticalScroller]

So it turns out you can use categories to override the scroller width method for all NSScrollers.

Eg. In NSScroller-MyScroller.h:

#import <Cocoa/Cocoa.h>

@interface NSScroller (MyScroller)

+ (CGFloat)scrollerWidth;
+ (CGFloat)scrollerWidthForControlSize: (NSControlSize)controlSize;

@end

In NSScroller-MyScroller.m:

#import "NSScroller-MyScroller.h"
#define SCROLLER_WIDTH 30.0

@implementation NSScroller (MyScroller)

+ (CGFloat)scrollerWidth {
    return SCROLLER_WIDTH;
}

+ (CGFloat)scrollerWidthForControlSize: (NSControlSize)controlSize {
    return SCROLLER_WIDTH;
}

@end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM