Thanks, Quincy, I'll try that.
On Mar 8, 2011, at 17:30:45, Quincey Morris wrote:
> 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 protected])
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 [email protected]