• 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: Set and show NSSlider position using code (not with mouse)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set and show NSSlider position using code (not with mouse)


  • Subject: Re: Set and show NSSlider position using code (not with mouse)
  • From: publiclook <email@hidden>
  • Date: Wed, 16 Jul 2003 21:29:19 -0400

On Wednesday, July 16, 2003, at 09:15 PM, Jeff Skrysak wrote:

I've got an application with an NSSlider, and it works okay. The user
can set
it, move it, etc...
Let's say that the slider has a minimum of 0.0 and a maximum of 1.0 and
the default starting point is 1.0

Now, the functionality I am working on adding is the ability to save
the slider's value
as a preference (easily done) and then when they open the program back
up again,
the slider starts at the value they last chose (the hard part).

I'm having trouble with that last part. Here's my code:

[speedSlider setFloatValue: [defaults floatForKey:@"Speed"]];
[speedSlider setNeedsDisplay:YES];


Make sure speedSlider is not nil as it may be early in app initialization. Consider using -awakeFromNib or -applicationDidFinishLaunching: as a place to set the slider's value.


But it doesn't work. The slider just starts out at 1.0, not 0.5 or any
other value that
is stored in the user defaults. I get the value from the user defaults,
and then
try to set the slider's value equal to it. I then say it needs to be
displayed, all in the hopes
that the slider will change position. No dice.

How do I make the slider move, using code?

-setFloatValue: is a fine way to move the slider, and you don't need to call -setNeedsDisplay: right after setting the float value because -setFloatValue: calls it for you.

How do I set it's current position, and make it show that in the GUI?

Thanks for any help.

- Jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Set and show NSSlider position using code (not with mouse) (From: Jeff Skrysak <email@hidden>)

  • Prev by Date: Set and show NSSlider position using code (not with mouse)
  • Next by Date: Hiding an NSMenu, or making keyboard shortcuts not tied to a menu item?
  • Previous by thread: Set and show NSSlider position using code (not with mouse)
  • Next by thread: Hiding an NSMenu, or making keyboard shortcuts not tied to a menu item?
  • Index(es):
    • Date
    • Thread