简体   繁体   中英

Detect column drag or resize in NSTableView while it is happening in Swift

I am working with an NSTableView in a macOS application and am trying to keep an arrow image next to the header drag bar of the currently sorted column. I have successfully been able to place the arrow next to the drag bar, but it only updates its position when the drag is released. I need it to update its position while the column-drag/resize is happening.

I have tried using the tableView(_:mouseDraggedWith:) , mouseDragged(with event: NSEvent) and tableView(_:didDrag:) delegate methods, but the mouseDragged functions don't trigger during column resizing, and the didDrag method triggers only upon mouse release.

I have also attempted to use the NSTableView.columnDidMoveNotification notification, but it also only triggers after the drag is released.

How can I detect the drag or resize of a column while it's happening, prior to the mouse click being released?

NSTableView has a method, setIndicatorImage(_:in:) , that puts an image at the right end of a column header (where the sort indicator may be displayed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM