Opening links in background with Cocoa
One of my biggest annoyances with mac software is how it handles opening links. This is usually a disruptive process that requires you to switch from your current task and application to another. Since I use spaces to partition apps (more info), it often results in not only switching apps, but also spaces, which makes it all the more annoying. Now, it makes sense if you click a link, that you want to view that page right away, but usually I'm not opening links to read them now, but to read them soon.
For example, if I'm reading an email that has links, I want to open them as I read it so I don't forget to look at them, but I don't want to have to switch applications mid-sentence just to open a url. This is even more prevalent when reading feeds. I use NetNewsWire for my RSS reader, but I don't use it to actually read the content. I like going to the site. I just use an RSS reader as means to get there more efficiently. So as I go through the links, if there is something interesting, I open the link. When I've gone through all the new items, I have everything open in tabs in Firefox. I find it too jarring to open a link, read it, go back to NNW, open a link, read it, etc. NNW handles this with ease by having a "Open links in background" preference. A simple one checkbox option that makes the experience all that more enjoyable and seamless for me.
So, to all developers out there, if your app involves people opening links, please provide this functionality. It's the attention to detail on these types of user interactions that really make or break an application. And so there's no excuse, here's an objective-c method to do it for you:
// Opens a URL in the default browser in background or foreground - (void)openURL:(NSString *)url inBackground:(BOOL)background { if (background) { NSArray* urls = [NSArray arrayWithObject:[NSURL URLWithString:url]]; [[NSWorkspace sharedWorkspace] openURLs:urls withAppBundleIdentifier:nil options:NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor:nil launchIdentifiers:nil]; } else { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]]; } }
A few lines of code and your app just became 10x more useful to me. While we're on links and usability. If your app does implement this functionality, make sure to provide some indication that the click actually worked or users will keep clicking the link all the while opening the same page a hundred times in their browser. NetNewsWire handles this by providing a subtle animation and changing the color of the text of the links you opened.