Where is NSBrowserSelectionDidChangeNotification when you need it?

While I was updating MacHg to include QuickLook support I came across the case where it would be really nice if NSBrowser had the notification NSBrowserSelectionDidChangeNotification (which doesn’t exist) whereas for comparison NSTableView hasĀ NSTableViewSelectionDidChangeNotification. There are a couple of hacks and ways to get around this, and MacHg currently updates more often than it should. Right now I just target the action to a method which always updates, but sometimes the selection updates when it doesn’t need to… Googling around for this, you can see various people searching for a solution… Eg here and here. Anyway, if anyone knows of a nice way to do this, please let me know!

Thanks,

Jason

1 Comment »

  1. Jason Said,

    January 21, 2012 @ 5:09 pm

    Well it turns out that in 10.6 there is a delegate method:

    • (NSIndexSet)browser:(NSBrowser)browser selectionIndexesForProposedSelection:(NSIndexSet*)proposedSelectionIndexes inColumn:(NSInteger)column

    Which you can implement in your delegate. This isn’t quite what is needed since it fires before the selection is actually changed, but using a performSelector:withObject:afterDelay: with a suitable small delay you might be able to fake the missing NSBrowserSelectionDidChangeNotification. At least I used this in MacHg… to get around the absence of this notification.

Leave a Comment