NSScrollView scroll wheel problem

  • I have an NSScrollView with a custom subview as its documentView. I
    have set the NSScrollView up in IB and set it so that it
    automatically hides scrollers. My problem occurs after resizing the
    window so that the scroll bars appear, then resizing it again so that
    they disappear. After doing that when I use the mighty mouse scroll
    wheel the NSScrollView's document view ( my custom view ) disappears.
    When I resize the window it pops back into view. I have implemented
    the following fix in my custom view that solves the problem but it
    shouldn't be necessary.

    - (void)scrollWheel:(NSEvent *)theEvent
    {
        NSScrollView *scrollView;
        NSRect horizontalScrollerRect;
        NSRect verticalScrollerRect;

        scrollView = (NSScrollView *)[[self superview] superview]; //my
    superview is the NSClipView, the NSClipView's super view is NSScrollView
        verticalScrollerRect = [[scrollView verticalScroller]
    rectForPart:NSScrollerKnobSlot];
        horizontalScrollerRect = [[scrollView horizontalScroller]
    rectForPart:NSScrollerKnobSlot];
        if ( [scrollView hasHorizontalScroller] && [self
    bounds].size.width > horizontalScrollerRect.size.width ) {
            [super scrollWheel:theEvent];
        }
        if ( [scrollView hasVerticalScroller] && [self
    bounds].size.height > verticalScrollerRect.size.height ) {
            [super scrollWheel:theEvent];
        }
    }
    Any information would be greatly appreciated.

    Thanks,
    Matt
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today