Re:Navigating a TableView: A Solution
Re:Navigating a TableView: A Solution
- Subject: Re:Navigating a TableView: A Solution
- From: Peter Bates <email@hidden>
- Date: Sun, 12 Mar 2006 08:52:45 -0700
Thanks Matt. Your reply made me smile. So there must be a better way.
This was my reasoning.
I subclassed NSWindow so I could catch the keyDown event, which it
seems is not passed on from the field editor when one edits a table
cell. The first responder is the cell rather than the table (which
is the delegate of the cell). So I needed a way to capture the event
and pass it on to the table. Subclassing NSTableView was a way for
me to deal with the keyDown event as I desired. I thought about
using a category method, but each table (I have 5) will handle a
different data set that needs to be loaded from, and archived to the
database manager. So it just seemed easier for me to deal
individually with each situation by providing subclasses to contain
the somewhat varied processing that is required.
So I have the feeling that I'm missing something significant. If so,
please point me in the right direction.
BTW I did simplify the window code a little, as below.
- sendEvent:(NSEvent *) theEvent
{
if ([theEvent type] == NSKeyDown)
{
NSResponder * fr;
fr=[self firstResponder];
switch ([[theEvent charactersIgnoringModifiers] characterAtIndex:0])
{
// Caution: this will pick up the following keyDown events in any
// NSText object that uses one of the target tableViews as as
delegate
case NSUpArrowFunctionKey:
case NSDownArrowFunctionKey:
case NSTabCharacter:
if([fr isKindOfClass:[NSText class]])
{
if([fr delegate]==myFirstTable)
{
[myFirstTable keyDown:theEvent];
}
else if([fr delegate]==mySecondTable)
{
[mySecondTable keyDown:theEvent];
}
else if([fr delegate]==myThirdTable)
{
[myThirdTable keyDown:theEvent];
}
}
break;
}
}
// Let someone else deal with other events
[super sendEvent:theEvent];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden