0

I've spent many hours trying to figure this one out with no luck. Someone had a similar problem on the Apple mailing lists a while ago and no one answered. Basically, it comes down to this: I've subclassed NSTextFieldCell and overridden the drawWithFrame: method to create a custom bezel. Then I call drawInteriorWithFrame: at the end of the method to draw the text. Everything works perfectly except for the fact that sometimes the text disappears. Everything else is drawn, except for the text. I think it might have something to do with the field editor, but I really don't know. Has anyone run into this problem before?

danjonweb
  • 456
  • 3
  • 14
  • Post your code. Your question is impossible to tell otherwise. – Joshua Nozzi Oct 31 '10 at 20:03
  • I can't post original code because it's tightly integrated with a big project. I tried to create an example project that repeats the unexpected behavior and of course I can't. Everything works exactly as expected :(. How am I supposed to debug something like this? By the way, whenever I resize the window, for example, and force the textfield to redraw, it draws the text correctly. So it's just a drawing problem and I don't know what I can do to fix it... – danjonweb Oct 31 '10 at 21:17
  • Then it's not possible to give any kind of direct answer. – Joshua Nozzi Nov 01 '10 at 00:51

1 Answers1

0

I apologize that this question wasn't better, but I feel others might run into this mysterious drawing problem someday and I have found a solution. The key to subclassing NSTextFieldCell is that when you override drawWithFrame:, you want to call [super drawWithFrame:] or else you might get these rendering problems. You can set the backgroundColor of the cell to whatever you want and use setClip to get the desired look, but you don't want to do all of the drawing yourself. At least this worked for me.

danjonweb
  • 456
  • 3
  • 14