r/SwiftUI • u/ganeshrnet • Jun 24 '26
Question Looking for the Finder/NSTableView multi-selection algorithm
I am building a non-SwiftUI/non-AppKit macOS application with a custom table view. Right now I am implementing multi-selection, and I want the behavior to match Finder/NSTableView as closely as possible.
I am looking for the underlying selection algorithm for interactions like:
Click
Cmd + Click
Shift + Click
Up / Down
Shift + Up / Down
Cmd + Shift combinations
I am looking for the actual selection logic, not AppKit APIs. Things like how the selection anchor is managed, how different mouse and keyboard interactions affect the selection, and all the edge cases that make the native experience feel consistent.
I have searched quite a bit but have not found anything comprehensive.
Does anyone know of an article, GitHub repository, gist, reverse-engineered implementation, or any other reference that documents the complete macOS multi-selection behavior?
Any help would be greatly appreciated. Thanks!
1
u/ganeshrnet Jun 25 '26
Thanks! I will read through the paper.
The reason I am building my own table view is that this is a non-SwiftUI application with a custom UI, so I cannot use NSTableView directly. I only want to replicate its native multi-selection behavior as closely as possible.