Is there a simple way to disable scrolling of an NSTableView.
It seems there isn't any property on
[myTableView enclosingScrollView]
or [[myTableView enclosingScrollView] contentView]
to disable it.
Is there a simple way to disable scrolling of an NSTableView.
It seems there isn't any property on
[myTableView enclosingScrollView]
or [[myTableView enclosingScrollView] contentView]
to disable it.
Works for me:
There is no simple direct way (meaning, there's no property like UITableView's
scrollEnabled
that you can set), but i found this answer helpful in the past.One other thing you could try (not sure about this) is subclassing
NSTableView
and override-scrollWheel
and-swipeWithEvent
so they do nothing. Hope this helpsThis works for me: subclass NSScrollView, setup and override via:
I hope this helps.
Here's the best solution in my opinion:
Swift 4
Simply replace any
NSScrollView
withDisablableScrollView
(orBCLDisablableScrollView
if you still use ObjC) and you're done. Simply setisEnabled
in code or in IB and it will work as expected.The main advantage that this has is for nested scroll views; disabling children without sending the event to the next responder will also effectively disable parents while the cursor is over the disabled child.
Here are all advantages of this approach listed out:
NSScrollView
Thanks to @titusmagnus for the answer, but I made one modification so as not to break scrolling when when the "disabled" scrollView is nested within another scrollView: You can't scroll the outer scrollView while the cursor is within the bounds of the inner scrollView. If you do this...
...then the "disabled" scrollView will pass the scroll event up to the outer scrollView and its scrolling will not get stuck down inside its subviews.