Matt Gemmell

My new book CHANGER is out now!

An action-thriller novel — book 1 in the KESTREL series.

★★★★★ — Amazon

Cocoa snap-to-edge windows

Source 1 min read

A while back, I wanted to implement snap-to-edge windows; proper ones like BBEdit’s HTML tools and Photoshop’s assorted tabbed palettes.

Someone pointed me to the Fire source, but I didn’t like that implementation; it made the windows snap after you dragged, giving an unpleasant “bobbing” effect, like the way an air-filled bottle bobs back to the surface of the water after you push it down. (Incidentally, Fire is a fabulous app. If you need to manage multiple instant messaging accounts on several different services - including MSN, AIM, Yahoo and ICQ - then you really should be using it.)

Anyway, I implemented my own snap-to-edge windows, and I’ve finally gotten around to cleaning up the source, adding plenty of comments, and making it available. You can grab the source (including a sample app) here (55k StuffIt archive as Binhex).