PDA

View Full Version : NSStepper class




rethish
Nov 3, 2008, 10:25 PM
How to use NSStepper? Give a simple example



lee1210
Nov 3, 2008, 10:51 PM
http://www.cocoadev.com/index.pl?NSStepperUnusable

There's an example here to download, plus a code snippet in the thread itself.

-Lee

kainjow
Nov 3, 2008, 10:56 PM
Well steppers first need a minimum and maximum value and a starting value:
[stepper setMinValue:0.0];
[stepper setMaxValue:100.0];
[steper setDoubleValue:50.0];
To know when the stepper value has changed, give it a target and action. This is usually done in Interface Builder. Then in the action method you can access the stepper's value like any other control (since it inherits from NSControl):
- (IBAction)stepperAction:(id)sender {
[textField setDoubleValue:[stepper doubleValue]];
}