Re: Waiting on NSTableView to finish changing selection
Re: Waiting on NSTableView to finish changing selection
- Subject: Re: Waiting on NSTableView to finish changing selection
- From: "Adam R. Maxwell" <email@hidden>
- Date: Wed, 08 Jul 2009 10:24:31 -0700
On Jul 8, 2009, at 10:15 AM, Kyle Sluder wrote:
On Wed, Jul 8, 2009 at 8:33 AM, Allan Donald<email@hidden> 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];
}
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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