Flicker from NSResponder Chain?
Flicker from NSResponder Chain?
- Subject: Flicker from NSResponder Chain?
- From: John MacMullin <email@hidden>
- Date: Tue, 15 Jul 2008 16:54:50 -0700
I read in the archives of a method to implement Tiger's approach to
tabbing through a table in Leopard. While my approach works as to the
tabbing, it is slightly different than the approach discussed in the
archives. It also results in a problem that is discussed below. I
have two tables in the tabview. One is a transaction table, which I
tab through. The other is a static table from which I develop
transactions for the transaction table.
The code for tabbing is in three parts:
I have an observer for the NSTextDidEndEditingNotification with the
selector being "localTextEditingDidEnd", which follows. This is
different from the subclass approach but works nonetheless. There is
a second observer for the select_EditedTableColumAndRow notification.
-(void)localTextEditingDidEnd:(NSNotification *)notification
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"] intValue];
if ([transactionTableView selectedRow] >= 0) {
int selectedRowOfTable = [transactionTableView selectedRow];
if ((lastColumnEdited == (int)columnOne) || (lastColumnEdited ==
(int)columnTwo)) {
int numberOfEntries = 0;
if (local_Tran_Array) {
numberOfEntries = [local_Tran_Array count];
}
BOOL lastRow = NO;
int indexOfLastRow = numberOfEntries - 1;
if (indexOfLastRow == selectedRowOfTable) {
lastRow = YES;
}
int nextColumn = 0;
int nextRow = 0;
if ((textMovement == NSTabTextMovement) || (textMovement ==
NSReturnTextMovement)) {
switch (lastColumnEdited) {
case columnOne:
nextColumn = columnTwo;
nextRow = selectedRowOfTable;
break;
case columnTwo:
if (lastRow) {
nextRow = 0;
} else {
nextRow = selectedRowOfTable + 1;
};
nextColumn = columnOne;
break;
default:
break;
}
NSNumber *next_column = [NSNumber numberWithInt:nextColumn];
NSNumber *next_row = [NSNumber numberWithInt:nextRow];
NSMutableDictionary *userInfo = [[[NSMutableDictionary
alloc]init]autorelease];
[userInfo setObject: next_column forKey:@"next_column"];
[userInfo setObject: next_row forKey:@"next_row"];
[[NSNotificationQueue defaultQueue] enqueueNotification:
[NSNotification notificationWithName:@"select_EditedTableColumAndRow"
object:nil userInfo:[NSDictionary dictionaryWithDictionary:userInfo]]
postingStyle: NSPostWhenIdle coalesceMask:NSNotificationNoCoalescing
forModes:nil];
}
}
} else {
lastColumnEdited = -1;
}
[pool release];
}
3. The common editcolum routine is also used by the tableview
selectionDidChange delegate hence the notification approach.
-(void)select_EditedTableColumAndRow:(NSNotification *)aNotification
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
NSDictionary *userInfo = [aNotification userInfo];
NSNumber *next_column = (NSNumber *)[userInfo
objectForKey:@"next_column"];
NSNumber *next_row = (NSNumber *)[userInfo objectForKey:@"next_row"];
[myWindowOutlet makeFirstResponder:[[[transactionTableView
tableColumnWithIdentifier:[next_column stringValue]] dataCellForRow:
[next_row intValue]] controlView]];
[transactionTableView scrollRowToVisible:(int)[next_row intValue]];
[transactionTableView selectRow:[next_row intValue]
byExtendingSelection:NO];
[transactionTableView editColumn:[next_column intValue] row:[next_row
intValue] withEvent:nil select:(BOOL)YES];
lastColumnEdited = [transactionTableView editedColumn];
[pool release];
}
This code works. The problem however is that the static table
"flickers" upon tabbing from one row to another row in the transaction
table. I suspect that this is a responder issue and that the
responder chain goes from the transaction table to the static table
then immediately back to the newly selected row in the transaction
table. I have tried every combination of makeFirstResponder in this
code and the tableview selectionDidChange delegate that I can think of
to eliminate the static table flicker with no good results at all.
Any help with understanding and resolving the "flicker" problem would
be greatly appreciated.
John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden