FROM : Scott Anguish
DATE : Fri Jan 24 20:51:01 2003
On Friday, January 24, 2003, at 09:46 AM, Geoff Coffey wrote:
> Can someone point me in the general direction of documentation about
> how focus rings work? I've subclassed NSTableView to add some keyboard
> input (type-to-select) and I'd like to put a focus ring around it. Do
> I just draw the thing myself, and if so, how do I draw outside my
> tableview?
>
> I assumed this would be as easy as everything else, but I've looked
> the docs up and down and see only passing mention of focus rings and
> no real explanation.
>
Somewhere in your draw routine, do the following
// If we have focus, draw a focus ring around the entire cellFrame
(inset it a little so it looks nice).
if ([self showsFirstResponder]) {
// showsFirstResponder is set for us by the NSControl that is drawing
us.
NSRect focusRingFrame = clockRect;
focusRingFrame.size.height -= 2.0;
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame,4,4)]
fill];
[NSGraphicsContext restoreGraphicsState];
}
DATE : Fri Jan 24 20:51:01 2003
On Friday, January 24, 2003, at 09:46 AM, Geoff Coffey wrote:
> Can someone point me in the general direction of documentation about
> how focus rings work? I've subclassed NSTableView to add some keyboard
> input (type-to-select) and I'd like to put a focus ring around it. Do
> I just draw the thing myself, and if so, how do I draw outside my
> tableview?
>
> I assumed this would be as easy as everything else, but I've looked
> the docs up and down and see only passing mention of focus rings and
> no real explanation.
>
Somewhere in your draw routine, do the following
// If we have focus, draw a focus ring around the entire cellFrame
(inset it a little so it looks nice).
if ([self showsFirstResponder]) {
// showsFirstResponder is set for us by the NSControl that is drawing
us.
NSRect focusRingFrame = clockRect;
focusRingFrame.size.height -= 2.0;
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle(NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame,4,4)]
fill];
[NSGraphicsContext restoreGraphicsState];
}
| Related mails | Author | Date |
|---|---|---|
| Geoff Coffey | Jan 24, 06:51 | |
| Scott Anguish | Jan 24, 20:51 |






Cocoa mail archive

