• 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: Update slider position
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Update slider position


  • Subject: Re: Update slider position
  • From: "Kyle Sluder" <email@hidden>
  • Date: Sun, 11 May 2008 14:35:02 -0400

On Sun, May 11, 2008 at 12:50 PM, Mike <email@hidden> wrote:
>  I have NSTextField which is connected to a slider in IB with its (Sent
> Actions = Take Double Value from).

Don't do this.  See below.

>  (Apparently I can't have them both connected to each other AND still have
> connection to my controller when either is changed?)

Nope.  It doesn't make sense to have multiple things connected to one
outlet; that's why you have a controller.  That said, it does make
sense for something to be connected to multiple outlets.

>  Q: How do I make that reset to reflect to slider too without having another
> outlet and do it manually?

First you should review some introductory material on
model-view-controller.  In your setup, this is what you would do:

1. Create a controller object that has an IBAction method.  Something
like - (void)takeMyValue:(id)sender.
2. Add two outlets to your controller: an NSSlider* and an NSTextField*.
3. Wire up the target/action of both your slider and text field to
your controller object's -takeMyValue: method.
4. Wire up the NSSlider and NSTextField outlets of your controller
object to their respective views.
5. In -takeMyValue:, send both your slider and text field a
-setFloatValue: message with [sender floatValue] as the argument.

Here's an example of this pattern so you can see how it plays out:
http://cocoadevcentral.com/articles/000045.php

Or, instead of writing all this glue code, you can use bindings.  Make
a KVC-compliant property in your model and bind both the slider and
text field to that keypath.  No code required.

--Kyle Sluder
_______________________________________________

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

References: 
 >Update slider position (From: Mike <email@hidden>)

  • Prev by Date: Re: Cocoa string to carbon compatible C string
  • Next by Date: Re: image opacity?
  • Previous by thread: Update slider position
  • Next by thread: Cocoa string to carbon compatible C string
  • Index(es):
    • Date
    • Thread