alexrozanski / PXSourceList

Source List control for the Mac
Other
639 stars 77 forks source link

Keep selected SourceList item selected when losing focus #44

Closed ThanosSiopoudis closed 10 years ago

ThanosSiopoudis commented 10 years ago

As per Apple's implementation, the selected sourcelist item shouldn't lose focus when a different control that takes FirstResponder is clicked.

Fixes #38

alexrozanski commented 10 years ago

Hey, thanks for the PR! There are a couple of things here:

I'll take your changes and take a look!

alexrozanski commented 10 years ago

Given that a custom row view can also be provided by the Source List's delegate, we should grab the this view first and just set emphasized to YES.

alexrozanski commented 10 years ago

I've had some more thought about this and I think that for now, the best way forward if you don't want the Source List to appear as if its lost focus is to implement your own row view which overrides -isEmphasized and returns YES. I think that because Apple doesn't specify this in the HIG, it's hard to say what the 'right' course of action is.

The implementation is also a bit tricky; what if you want to use your own NSTableRowView? If there's an option to turn the always-focussed appearance on, what happens if you implement your own NSTableRowView and don't override -isEmphasized to return YES?

There may be a possibility of implementing a breaking API change to turn this on/off by requiring -sourceList:rowViewForItem: to return a PXSourceListTableRowView so I'll consider this for PXSourceList 3.0

Thanks again for the PR!

ThanosSiopoudis commented 10 years ago

Hi, no worries, I understand your concerns. Why would this be a breaking API change? Can't the user subclass PXSrouceListTableRowView which would have a property to set -isEmphasized to YES, instead of subclassing NSTableRowView? This would of course require changes to my PR but I think it can still be done.

From a UX point of view - and I might be wrong - I think Apple is using emphasised items when the sidebar is a list of items, and non-emphasised items when it's a file list view. It also looks a little more consistent in 10.10 as well, as Mail no longer loses focus when selecting an item outside the sidebar.

alexrozanski commented 10 years ago

I'd say that requiring the user to subclass PXSourceListTableRowView is a breaking API change (although I agree it's a bit of a grey area). I've made an issue for this though so I'll revisit it for the next major update.