Recently the topic of selections in Cocoa apps came up again. While most of the discussion has centered around selections in text, the majority of sane developers use AppKit’s built-in text views and leave it at that. However, when we were developing Mercatalog’s interface over at Calf Trail, we needed to handle mouse selection and dragging of photo icons in a consistent way. Not only did our map and timeline layers need to behave similarly, they had to work like the rest of the operating system.
Cocoa leaves selection handling completely up to each individual view. As our view code developed, we realized that this task was less trivial than it first seemed. Playing around with various views in other apps to determine the “correct” behaviour was even less encouraging — there are many selection idiosyncrasies among Apple’s applications and views.
So we tried to solve the problem once and for all, in a separate class intended to manage selection and drag source behaviour for any view/cell/layer that needs it. It’s mostly geared towards mouse selection at this point, but Calf Trail is making it available as open source in the hopes it will spark discussion and progress towards good selection behaviour. You can find details and source for TLSelectionManager on Google Code.