Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out whether NSScrollView is currently scrolling

How can I find out whether my NSScrollView is currently scrolling? On iOS I can use the delegate but despite of googling a lot I can't find a way to do this on the Mac.

Thanks in advance!

like image 490
icant Avatar asked Dec 16 '12 13:12

icant


1 Answers

You can receive notification NSViewBoundsDidChangeNotification like shown below

NSView *contentView = [scrollview contentView];

[contentView setPostsBoundsChangedNotifications:YES];

// a register for those notifications on the content view.
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(boundDidChange:)
                                             name:NSViewBoundsDidChangeNotification
                                           object:contentView];

The notification method

- (void)boundDidChange:(NSNotification *)notification {
    // get the changed content view from the notification
    NSClipView *changedContentView=[notification object];
}
like image 160
dafi Avatar answered Nov 15 '22 04:11

dafi