Re: [Q] How to frame NSTableView and NSOutlineView?
Re: [Q] How to frame NSTableView and NSOutlineView?
- Subject: Re: [Q] How to frame NSTableView and NSOutlineView?
- From: Mark de Jong <email@hidden>
- Date: Tue, 23 Jul 2002 07:06:49 -0700
Wow! This is great. Thank you very much!
-- Mark
On Tuesday, July 23, 2002, at 05:12 AM, Cristian Savu wrote:
I have a window with several NSTableViews and NSOutlineViews.
I'd like
to be able to frame (draw a rect) around the table or outline
that has
the current "focus." Iow, the last table or outline that was
clicked in
or tabbed to, to give user feedback as which one can have
certain tools
acted upon.
Here you have the code you need. Just add this files to IB and instead
of
NSScrollView use this class.
This code is not the creation of my neuron. I found it on this list. I
think
mmalcom is the author, but I can't be sure.
Hope it works.
Regards, Cristian
// RSFocusScrollView.h
#import <Cocoa/Cocoa.h>
@interface RSFocusScrollView : NSScrollView
{
BOOL shouldDrawFocusRing;
NSResponder *lastResp;
}
@end
// RSFocusScrollView.m
#import "RSFocusScrollView.h"
@implementation RSFocusScrollView
- (BOOL)needsDisplay
{
NSResponder *resp = nil;
if ([[self window] isKeyWindow])
{
resp = [[self window] firstResponder];
if (resp == lastResp) return [super needsDisplay];
}
else if (lastResp == nil)
{
return [super needsDisplay];
}
shouldDrawFocusRing = (resp != nil && [resp isKindOfClass: [NSView
class]] && [(NSView *)resp isDescendantOf: self]); // [sic]
lastResp = resp;
[self setKeyboardFocusRingNeedsDisplayInRect: [self bounds]];
return YES;
}
- (void)drawRect:(NSRect)rect
{
[super drawRect: rect];
if (shouldDrawFocusRing)
{
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill(rect);
}
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.