How tell if NSTableView is already displaying its last row entirely?

I am no expert at coordinate systems. I am kind of aware I can use its enclosingScrollView but don't know the details.

Any suggestions would be appreciated.

Replies

I have not tested, but I would try to read the scroll position and check if it is at the maximum.

Get details here: https://saeedrz.medium.com/detect-scroll-position-in-swiftui-3d6e0d81fc6b#:~:text=To%20detect%20the%20scroll%20position,to%20a%20given%20coordinate%20system.

  • I am on Appkit, it seems NSScrollView does not have onChange event, and I cannot find any properties/notifications that can tell me the current scroll position. That's odd.

Add a Comment

At last, I found the answer myself, again. The answer lies in NSScroller.floatValue which inherited from NSControl.

let shouldDelegate = {
    if let scroller = scrollView.verticalScroller {
        return scroller.isHidden || scroller.floatValue == 0 || scroller.floatValue == 1.0
    }
    return true
}()