NSScroller subclassification, how to get rid of the white square in the lower right corner?

I created an iTunes subclass as a subclass of NSScroller, however, if both horizontal and vertical scrollers are visible in NSScrollView or NSTableView, I am left with an ugly white square in the lower right corner. Does anyone know where to add your own drawing to fill it with something more beautiful?

+3
source share
1 answer

Ok, I think I have the solution (s).

  • Or you specify scrollview not to draw its background, in this case everything below it will fill the corner.

  • Or, as I did, you will override the scrollview drawRect method with the following:

    - (void)drawRect:(NSRect)rect{
       [super drawRect: rect];
    
       if([self hasVerticalScroller] && [self hasHorizontalScroller]){
         NSRect vframe = [[self verticalScroller]frame];
         NSRect hframe = [[self horizontalScroller]frame];
         NSRect corner;
         corner.origin.x = NSMaxX(hframe);
         corner.origin.y = NSMinY(hframe);
         corner.size.width = NSWidth(vframe);
         corner.size.height = NSHeight(hframe);
         // your custom drawing in the corner rect here
      }
    }
    
+3

Source: https://habr.com/ru/post/1727704/


All Articles