• 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: Updating binding on release of slider (but update text field continuously)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Updating binding on release of slider (but update text field continuously)?


  • Subject: Re: Updating binding on release of slider (but update text field continuously)?
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 08 Mar 2011 17:30:45 -0800

On Mar 8, 2011, at 17:18, Rick Mann wrote:

> I have a UI with an editable text field and a slider. I want the two to represent the same model property. I only want the model updated when the user exits the text field or lets go of the slider (which is what it does now).
>
> However, I'd like it if the text field would update continuously as the slider is dragged.
>
> I don't think it's possible to do this with bindings, is it?

Not exactly. To get the UI behavior you want, you need to create in intermediate property in the window controller, and bind the text field and the slider to that.

You can make this property dependent on the model property using '+keyPathsForValuesAffecting...'.

All that remains is to defer updating the model until the editing or sliding operation is complete. I don't think you can do that with bindings.

Probably the simplest way to put an action on the text field and the slider. That'll get triggered at the end of text editing, and during sliding. Something like this (in the window controller subclass):

- (IBAction) valueChanged: (id) sender {
	model.value = self.value;
}

- (IBAction) sliderValueChanged: (id) sender {
	[NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector (valueChanged:) object: nil];
	[self performSelector: @selector (valueChanged:) withObject: nil afterDelay: 0];
}

The second method (the slider's action method) is a hack to defer the action until the user lets go of slider.

(note: code typed in Mail)


_______________________________________________

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: Updating binding on release of slider (but update text field continuously)?
      • From: Rick Mann <email@hidden>
References: 
 >Updating binding on release of slider (but update text field continuously)? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: About notification NSWindowDidMiniaturizeNotification
  • Next by Date: Re: Updating binding on release of slider (but update text field continuously)?
  • Previous by thread: Updating binding on release of slider (but update text field continuously)?
  • Next by thread: Re: Updating binding on release of slider (but update text field continuously)?
  • Index(es):
    • Date
    • Thread