dejalbuttoncell

One of the features of Time Out 2 is a sidebar listing the breaks and options, as you could see (blurred somewhat) in my previous post . The sidebar includes a couple of buttons that appear when you hover the pointer over a row, enabling you to manually start or pause that break.

A vexing issue I had, though, was that the button didn't draw correctly. If you look closely at this screenshot, you may notice that the background of the text and the remainder of the button content don't match — there's a visible outline around the text:

That is rather ugly. I'm not sure exactly what causes it, but presumably it's related to being in a sidebar list, and perhaps an issue with title-less windows (I've seen some other issues, too).

Regardless, I wanted to fix it. After a bit of experimentation, I found a simple solution: a subclass of NSButtonCell to override the -drawTitle:withFrameinView: method, which as you might imagine is responsible for drawing the title text. The override simply invokes the superclass, and returns the full button rect instead of the rect of the text itself: