• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tabbing into NSTableView finally solved!!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tabbing into NSTableView finally solved!!


  • Subject: Re: Tabbing into NSTableView finally solved!!
  • From: Pierre-Olivier Latour <email@hidden>
  • Date: Mon, 09 Sep 2002 16:43:19 +0200

> On Sat, 07 Sep 2002 19:40:58 +0200, Pierre-Olivier Latour
> <email@hidden> said:
>
>> For those who haven't noticed: here's how to make your NSTableView become
>> first responder when the user presses tab: simply subclass NSTableView and
>> add this:
>>
>> - (BOOL) needsPanelToBecomeKey
>> {
>> return YES;
>> }
>
> I don't see what difference this makes; it still doesn't get a blue
> highlight ring, so the user will never know. m.

You're right, you also need to subclass the ScrollView that contains the
table so that it displays the focus ring if necessary:

@implementation FocusScrollView

- (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]);
lastResp = resp;
[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];

return YES;
}

- (void) drawRect:(NSRect)rect
{
[super drawRect:rect];
if(shouldDrawFocusRing) {
//[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; -
VISUAL BUG ON 10.2 when clicking in the list
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill([self bounds]);
}
}

@end

I'm sorry, I don't remember who wrote this code initially, but I think it
was on: http://www.cocoadev.com/

Note: this code is a kind of "hack" and does not seems to work the same on
10.1 or 10.2. Therefore my commented out line in drawRect


_____________________________________________________________

Pierre-Olivier Latour email@hidden
Lausanne, Switzerland http://www.pol-online.net
_______________________________________________
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.

References: 
 >Re: Tabbing into NSTableView finally solved!! (From: Matt Neuburg <email@hidden>)

  • Prev by Date: NSDrawer newbie question
  • Next by Date: Re: NSDocument:windowControllerDidLoadNib && When are outlets connected to te loaded nib?
  • Previous by thread: Re: Tabbing into NSTableView finally solved!!
  • Next by thread: Re: Tabbing into NSTableView finally solved!!
  • Index(es):
    • Date
    • Thread