On Jul 8, 2009, at 10:15 AM, Kyle Sluder wrote:
On Wed, Jul 8, 2009 at 8:33 AM, Allan Donald<li...@thehold.net> wrote:I've got an NSTableView that triggers some relatively expensive stuff when its selection changes. If the user is holding down one of the arrow keys to move through the list, I'd like to wait until they've finished before starting the operation. (Somewhat akin to what Mail.app does -- it won't update the message pane preview if the user's scrolling through a long list of messages with the arrow keys)Subclass NSTableView and override -keyDown: to set a flag (let's call it isKeyedScrolling) when appropriate. Override -keyUp:, and if isKeyedScrolling is true then fire a custom delegate method which performs your expensive update. Then clear isKeyedScrolling.
That sounds like a good way to do it. Another is to implement the table delegate to enqueue/coalesce a notification, then handle the queued notification separately to do the expensive work:
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {NSNotification *note = [NSNotification notificationWithName:@"QueuedTableSelectionDidChange" object:self]; [[NSNotificationQueue defaultQueue] enqueueNotification:note postingStyle:NSPostWhenIdle coalesceMask:NSNotificationCoalescingOnName forModes:nil];
}
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com