Notification for new NSTableView Group Row

147 views Asked by At

I'm looking to change the look of my row view when it becomes a group row, or possibly more specifically when it becomes the group row that is stuck at the top of the NSTableview.

I wondered if there was a notification or some property that could be checked. Ideally I'd like to do some kind of animation as it gets within range of the top from one view to the next.

I'm thinking along the lines of tracking the row views coordinates in relation to the clip view/scroll view... Would that be the approach you would take?

Any suggestions?

2

There are 2 answers

1
Ken Thomases On BEST ANSWER

when it becomes a group row

Are you expecting a row to change whether it is a group row over time?

I'm looking to change the look of my row view […] when it becomes the group row that is stuck at the top of the NSTableview.

Have the row view's -drawRect: method consult its own floating property and draw differently based on its value. You may need to override the -setFloating: setter to mark your row view as needing display, too.

0
Sammy The Hand On

Ken Thomases suggestion was just the suggestion I needed. I want to directly change the NSTableCellView so I called the following method from there, but you could also call it directly from a custom NSTableRowView.

From a custom NSTableCellView:

override func draw(_ dirtyRect: NSRect) {
    super.draw(dirtyRect)
    if let rowView = self.superview as? NSTableRowView, rowView.isFloating == true {
        Swift.print("Row is Floating")
    }
}

From a custom NSTableRowView:

override func draw(_ dirtyRect: NSRect) {
    super.draw(dirtyRect)
    if self.isFloating == true {
        Swift.print("Row is Floating")
    }
}

Allowing me to change the view as desired. Thankyou Ken