objective c - How to disable the mouse hover expand effect on a NSTextView's NSScrollView scroller? -
i have nstextview
, here's normal size of scroller:
, here's happens when hover scroller of textview:
however, don't want have 'expand' effect. how can remove it? i've tried search around on how perform this, couldn't find anything. want have regular scroller size (the thinner one) time, if user hovers it. possible?
thanks
i recommend subclassing nsscroller , override – drawarrow:highlight:
/ – drawknobslotinrect:highlight:
/ – drawknob
methods have stable scroller appearance.
p.s. don't forget set new scroller class in xib-file scrollers.
update
here sample code:
- (void)drawknob { // call default implementation overlay scrollers if (self.scrollerstyle == nsscrollerstyleoverlay) { [super drawknob]; return; } if (_style == nsscrollerknobstylelight || _style == nsscrollerknobstyledefault) [[nscolor colorwithcalibratedwhite:1.0 alpha:0.8] setfill]; else [[nscolor colorwithcalibratedwhite:0 alpha:0.4] setfill]; // note: can specify rect fixed width here nsrect knobrect = [self rectforpart:nsscrollerknob]; // vertical scroller nsinteger fullwidth = knobrect.size.width; knobrect.size.width = round(knobrect.size.width/2); knobrect.origin.x += (nsinteger)((fullwidth - knobrect.size.width)/2); // draw... nsbezierpath * thepath = [nsbezierpath bezierpath]; [thepath appendbezierpathwithroundedrect:knobrect xradius:4 yradius:4]; [thepath fill]; } //--------------------------------------------------------------- - (void)drawknobslotinrect:(nsrect)slotrect highlight:(bool)flag { // call default implementation overlay scrollers // draw nothing usual if (self.scrollerstyle == nsscrollerstyleoverlay) { [super drawknobslotinrect:slotrect highlight:flag]; } } //--------------------------------------------------------------- - (void)drawarrow:(nsscrollerarrow)whicharrow highlight:(bool)flag { // call default implementation overlay scrollers // draw nothing usual if (self.scrollerstyle == nsscrollerstyleoverlay) { [super drawarrow:whicharrow highlight:flag]; } }
Comments
Post a Comment