• 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: Re: Action while trcking, Different action on mouseUp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Action while trcking, Different action on mouseUp


  • Subject: Re: Re: Action while trcking, Different action on mouseUp
  • From: "Michael Ash" <email@hidden>
  • Date: Wed, 16 Aug 2006 15:43:45 -0400

On 8/16/06, Matt Neuburg <email@hidden> wrote:
On Mon, 14 Aug 2006 22:44:27 +0000, Trygve Inda <email@hidden>
said:
>I have an NSSlider that has an action (through a binding) to display the
>current slider value while tracking. I'd like a different action to call a
>method when the user releases the mouse to do stuff with the new setting.
>
>How can I enable this?

That's truly silly. How do you know the user will use the mouse to slide the
slider? It's perfectly possible to use the keyboard instead. m.

It's not that silly. Often a slider manipulates something that is intensive enough to recompute as to interfere with smooth mouse tracking. In the keyboard case you just swallow the cost and update all the time.

Fortunately it's easy to implement. Write your action like so:

- (void)sliderMoved: (id)sender {
  ... stuff you want to do with every new value, if any ...

  [NSObject cancelPreviousPerformRequestsWithTarget: self selector:
@selector( sliderCommit: ) object: nil];
  [self performSelector: @selector( sliderCommit: ) withObject: nil
afterDelay: 0.0];
}

- (void)sliderCommit: (id)ignore {
  ... this gets executed immediately after any keystroke or mouseup ...
}

The key here is that delayed performs, by default, are only executed
in the default runloop mode, but control tracking has a separate
runloop mode. You cancel old ones to make sure the commit only happens
once, and it gets executed at the end.

Mike
_______________________________________________
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


References: 
 >Re: Action while trcking, Different action on mouseUp (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Draw a TextFieldBorder only in edit mode
  • Next by Date: Glossy bar at bottom of Mail and NetNewsWire
  • Previous by thread: Re: Action while trcking, Different action on mouseUp
  • Next by thread: Re: Action while trcking, Different action on mouseUp
  • Index(es):
    • Date
    • Thread