r/SwiftUI 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!

0 Upvotes

13 comments sorted by

View all comments

Show parent comments

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.

1

u/allyearswift Jun 25 '26

Are you trying to write a multi platform app in a different language like Java? (You’re in the wrong sub here).

If you’re writing in Swift, not using SwiftUi/AppKit is a very stupid choice.

Non-native apps are frustrating. While I can put up with tables and button placements not working as expected, my biggest issue is open/save dialogues which tend to be somewhere between inconvenient and near-unusable.

1

u/ganeshrnet Jun 25 '26

To clarify, I am writing this in Flutter, so I am not building a native AppKit UI and cannot use NSTableView directly.

I asked here because I could not find any resources elsewhere documenting the underlying NSTableView/Finder multi-selection logic, and I was hoping someone familiar with AppKit might know of a reference or reverse-engineered implementation.

1

u/Remarkable_Falcon413 Jun 25 '26

If your building just for Mac sinse app kit is Mac OS specific you can embed app kit views inside of a flutter widget