• 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: NSSlider value difference in two places...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSlider value difference in two places...


  • Subject: Re: NSSlider value difference in two places...
  • From: "Peters, Brandon" <email@hidden>
  • Date: Mon, 02 Jun 2014 01:19:42 +0000
  • Thread-topic: NSSlider value difference in two places...

Graham,

For the first action:

Declaration:

    // allows user to set the value of the friction coefficient
    IBOutlet NSSlider *_frictionSlider;



    // displays friction coefficient chosen by the user
    IBOutlet NSTextField *_frictionDisplay;



    // allows user to set the mass
    IBOutlet NSSlider *_massSlider;



    // displays the mass chosen by the user
    IBOutlet NSTextField *_massDisplay;



    // allows the user to set the amount of forces applied to the ball
    IBOutlet NSSlider *_forceAppliedSlider;



    // displays the amount of force the user wishes to apply
    IBOutlet NSTextField *_forceAppliedDisplay;
}

When the sliders are moved:

-(IBAction)changeParameters:(id)sender
{
    // user adjusts slider for mass
    if([sender tag] == RBS_MassSliderTag)
    {
        [_massDisplay setFloatValue:[_massSlider floatValue]];
        NSLog(@"Mass in changeParameters: %f\n", [_massSlider floatValue]);
    }
    // user adjusts slider for friction
    else if([sender tag] == RBS_FrictionSliderTag)
    {
        [_frictionDisplay setFloatValue:[_frictionSlider floatValue]];
    }
    // user adjusts slider for force applied
    else
    {
        [_forceAppliedDisplay setFloatValue:[_forceAppliedSlider floatValue]];
    }
}

When the start button is pressed:

    // friction
    [_simulationView setFrictionCoefficient:[_frictionSlider floatValue]];



    // mass
    NSLog(@"Mass in startSimulation: %f\n", [_massSlider floatValue]);
    [_simulationView setMass:[_massSlider floatValue]];

On Jun 1, 2014, at 8:37 PM, Graham Cox <email@hidden<mailto:email@hidden>> wrote:


On 2 Jun 2014, at 10:28 am, Peters, Brandon <email@hidden<mailto:email@hidden>> wrote:

have a slider used to adjust a value. When the slider is moved, an action is triggered to display the value in a panel. When a start button is pressed, another action is triggered, and within that action the value of the slider is ascertained. I have discovered than when calling the second action, the value of the slider is zero, unlike the value when called from the first action. Is this expected behavior? How can get the slider to retain its value from the first called action? Thanks.


This isn't the expected behaviour; sliders and all controls have a value that they remember constantly. How are you referring to the slider in the second action? Using an outlet? Is it connected?

Show your code - something else is wrong.

--Graham



_______________________________________________

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: NSSlider value difference in two places...
      • From: Graham Cox <email@hidden>
References: 
 >NSSlider value difference in two places... (From: "Peters, Brandon" <email@hidden>)
 >Re: NSSlider value difference in two places... (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSSlider value difference in two places...
  • Next by Date: Re: NSSlider value difference in two places...
  • Previous by thread: Re: NSSlider value difference in two places...
  • Next by thread: Re: NSSlider value difference in two places...
  • Index(es):
    • Date
    • Thread