• 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: how to prevent TableView update on key repeat?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to prevent TableView update on key repeat?


  • Subject: Re: how to prevent TableView update on key repeat?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 03 May 2012 15:47:42 -0700

On May 3, 2012, at 15:27 , Marc Respass wrote:

> I ended up finding a solution that almost works perfectly.
>
> - (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
> {
>     NSEvent *event = [NSApp currentEvent];
>
>     if(event != nil && [event type] == NSKeyDown && [event isARepeat])
>     {
>         return;
>     }
>     else
>     {
> 	// do my thing
>     }
> }

Well, apologies in advance for being curmudgeonly, but this is a crummy solution.

You don't know, at the time this method is called, what the current event is. The table view itself might already have deferred sending the notification until some other event occurred (e.g. a NSTimer expiration, or it may even have done its own performSelector…afterDelay). That means that pressing a random key after an arrow key might suppress the detail update entirely.

On top of that, you're ready to jump in and double your hack by subclassing NSTableView to "fix" the problem the first hack had with keyUp events. Ugh!

The technique I suggested, of performing a selector and canceling unwanted performs, isn't "fragile". It's a well known (though not immediately obvious) pattern that works well in situations like this. I didn't invent it, I just learned it from someone else on this list. It also has the distinct advantage (in stark contrast to your hack) of being provably correct.



_______________________________________________

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


  • Follow-Ups:
    • Re: how to prevent TableView update on key repeat?
      • From: Marc Respass <email@hidden>
References: 
 >how to prevent TableView update on key repeat? (From: Marc Respass <email@hidden>)
 >Re: how to prevent TableView update on key repeat? (From: Quincey Morris <email@hidden>)
 >Re: how to prevent TableView update on key repeat? (From: Marc Respass <email@hidden>)

  • Prev by Date: Re: Xcode warns about missing protocol definition, even though @protocol is used
  • Next by Date: Re: how to prevent TableView update on key repeat?
  • Previous by thread: Re: how to prevent TableView update on key repeat?
  • Next by thread: Re: how to prevent TableView update on key repeat?
  • Index(es):
    • Date
    • Thread