Posted By

munrobaggers on 06/07/12


Tagged

cocoa cell


Versions (?)

Drawing a standard focus ring inside of a cell's bounds


 / Published in: Objective C
 

  1. - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
  2. {
  3. // other stuff might happen here
  4. if ([self showsFirstResponder]) {
  5. // showsFirstResponder is set for us by the NSControl that is drawing us.
  6. NSRect focusRingFrame = cellFrame;
  7. focusRingFrame.size.height -= 2.0f;
  8. [NSGraphicsContextsaveGraphicsState];
  9. NSSetFocusRingStyle(NSFocusRingOnly);
  10. [[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame, 4.0f, 4.0f)] fill];
  11. [NSGraphicsContext restoreGraphicsState];
  12. }
  13. // other stuff might happen here
  14. }

Report this snippet  

You need to login to post a comment.