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


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.