0

I am trying to disable all the subviews in a window. My code for implementing the same is as below:

public extension NSView {
    @objc func disableSubviews(_ disable: Bool) {
        for view: NSView in self.subviews as [NSView] {
            view.disableSubviews(disable)
            if let aControl = view as? NSControl {
                aControl.isEnabled = !disable
            }
        }
    }
}

And I am calling the function like this : self.view.window.contentView.disableSubviews(true) This works fine and disables all the controls except for NSScrollView(which has NSTableView). User is still able to interact and scroll the tableview, because of which app is crashing as the code is trying load data into the NSTableView. How to disable/enable a scrollView/tableView so that user is not able to interact with it until it is enabled again?

1 Answers1

-1

a) Put a transparent view on it, and disable it b) put gesture recognizer, that will take all gestures+touches and will not send it further c) Look for "how disable TableView" Sorry, this is not direct answer, but directions where to find the answer...