A common use of NSStepper is to control the value displayed in an adjacent text field. Here, I want to use this method to control text size in a simplified fashion. In IB, I set the stepper's minimum and maximum values and increment (all as floats).
One trick to steppers is that you should control drag from the stepper to the Text Field and then select takeIntValueFrom. This results in an action being sent to the TF to reflect changes in the stepper. Here, the stepper has been pre-set to have the values 12.0 and 14.0 with an increment of 2.0. These values can be changed in code, by making the stepper an outlet of the AD.
I also set the TextField as an outlet of the AppDelegate and get the stepper's value in awakeFromNib. Otherwise, the value is not displayed until the stepper is clicked for the first time.
To find out when the stepper has been clicked, just control drag from the stepper to the App Delegate in IB, the same as for any control. That's it.
class PyStepperAppDelegate(NSObject): |