Re: Set and show NSSlider position using code (not with mouse)
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.