Up

# NSSlider

### Authors

Ovidiu Predescu (`ovidiu@net-community.com`)
Felipe A. Rodriguez (`far@ix.netcom.com`)

Copyright: (C) 1996 Free Software Foundation, Inc.

# Class Description

An NSSlider displays, and allows control of, some value in the application. It represents a continuous stream of values of type `float`, which can be retrieved by the method `floatValue` and set by the method `setFloatValue:`.

This control is a continuous control. It sends its action message as long as the user is manipulating it. This can be changed by passing `NO` to the `setContinuous:` message of a given NSSlider.

Although methods for adding and managing a title are provided, the slider's knob can cover this title, so it is recommended that a label be added near the slider, for identification.

As with many controls, NSSlider relies on its cell counterpart, NSSliderCell. For more information, please see the specification for NSSliderCell.

Use of an NSSlider to do the role of an NSScroller is not recommended. A scroller is intended to represent the visible portion of a view, whereas a slider is intended to represent some value.

## NSSlider : NSControl

> Declared in:
>   AppKit/NSSlider.h

Availability: OpenStep
Description forthcoming.
Method summary

- -acceptsFirstMouse:
- -allowsTickMarkValuesOnly
- -altIncrementValue
- -closestTickMarkValueToValue:
- -image
- -indexOfTickMarkAtPoint:
- -isVertical
- -knobThickness
- -maxValue
- -minValue
- -numberOfTickMarks
- -rectOfTickMarkAtIndex:
- -setAllowsTickMarkValuesOnly:
- -setAltIncrementValue:
- -setImage:
- -setKnobThickness:
- -setMaxValue:
- -setMinValue:
- -setNumberOfTickMarks:
- -setTickMarkPosition:
- -setTitle:
- -setTitleCell:
- -setTitleColor:
- -setTitleFont:
- -tickMarkPosition
- -tickMarkValueAtIndex:
- -title
- -titleCell
- -titleColor
- -titleFont

### acceptsFirstMouse:

- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent;
Availability: OpenStep
Returns `YES` by default. This will allow the first click sent to the slider, when in an inactive window, to both bring the window into focus and manipulate the slider.

### allowsTickMarkValuesOnly

- (BOOL) allowsTickMarkValuesOnly;
Availability: MacOS-X 10.0.0
Description forthcoming.

### altIncrementValue

- (double) altIncrementValue;
Availability: OpenStep

Returns the value by which the slider will be incremented if the user holds down the ALT key.

See Also: -setAltIncrementValue:

### closestTickMarkValueToValue:

- (double) closestTickMarkValueToValue: (double)aValue;
Availability: MacOS-X 10.0.0
Description forthcoming.

### image

- (NSImage*) image;
Availability: OpenStep

Returns the image drawn in the slider's track. Returns `nil` if this has not been set.

See Also: -setImage:

### indexOfTickMarkAtPoint:

- (int) indexOfTickMarkAtPoint: (NSPoint)point;
Availability: MacOS-X 10.0.0
Description forthcoming.

### isVertical

- (int) isVertical;
Availability: OpenStep
Returns whether or not the slider is vertical. If, for some reason, this cannot be determined, for such reasons as the slider is not yet displayed, this method returns -1. Generally, a slider is considered vertical if its height is greater than its width.

### knobThickness

- (float) knobThickness;
Availability: OpenStep
Returns the thickness of the slider's knob. This value is in pixels, and is the size of the knob along the slider's track.

### maxValue

- (double) maxValue;
Availability: OpenStep

Returns the maximum value that the slider represents.

See Also: -setMaxValue:

### minValue

- (double) minValue;
Availability: OpenStep

Returns the minimum value that the slider represents.

See Also: -setMinValue:

### numberOfTickMarks

- (int) numberOfTickMarks;
Availability: MacOS-X 10.0.0
Description forthcoming.

### rectOfTickMarkAtIndex:

- (NSRect) rectOfTickMarkAtIndex: (int)index;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setAllowsTickMarkValuesOnly:

- (void) setAllowsTickMarkValuesOnly: (BOOL)flag;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setAltIncrementValue:

- (void) setAltIncrementValue: (double)increment;
Availability: OpenStep

Sets the value by which the slider will be incremented, when the ALT key is held down, to increment.

See Also: -altIncrementValue

### setImage:

- (void) setImage: (NSImage*)backgroundImage;
Availability: OpenStep

Sets the image to be displayed in the slider's track to barImage.

See Also: -image

### setKnobThickness:

- (void) setKnobThickness: (float)aFloat;
Availability: OpenStep

Sets the thickness of the knob to aFloat, in pixels. This value sets the amount of space which the knob takes up in the slider's track.

See Also: -knobThickness

### setMaxValue:

- (void) setMaxValue: (double)aDouble;
Availability: OpenStep

Sets the maximum value that the sliders represents to aDouble.

See Also: -maxValue

### setMinValue:

- (void) setMinValue: (double)aDouble;
Availability: OpenStep

Sets the minimum value that the slider represents to aDouble.

See Also: -minValue

### setNumberOfTickMarks:

- (void) setNumberOfTickMarks: (int)numberOfTickMarks;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setTickMarkPosition:

- (void) setTickMarkPosition: (NSTickMarkPosition)position;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setTitle:

- (void) setTitle: (NSString*)aString;
Availability: OpenStep

Sets the title of the slider to aString. This title is displayed on the slider's track, behind the knob.

See Also: -title

### setTitleCell:

- (void) setTitleCell: (NSCell*)aCell;
Availability: OpenStep

Sets the cell used to draw the title to aCell.

See Also: -titleCell

### setTitleColor:

- (void) setTitleColor: (NSColor*)aColor;
Availability: OpenStep

Sets the colour with which the title will be drawn to aColor.

See Also -titleColor

### setTitleFont:

- (void) setTitleFont: (NSFont*)fontObject;
Availability: OpenStep

Sets the font with which the title will be drawm to fontObject.

See Also: -titleFont

### tickMarkPosition

- (NSTickMarkPosition) tickMarkPosition;
Availability: MacOS-X 10.0.0
Description forthcoming.

### tickMarkValueAtIndex:

- (double) tickMarkValueAtIndex: (int)index;
Availability: MacOS-X 10.0.0
Description forthcoming.

### title

- (NSString*) title;
Availability: OpenStep

Returns the title of the slider as an `NSString`.

See Also: -setTitle:

### titleCell

- (id) titleCell;
Availability: OpenStep

Returns the cell used to draw the title.

See Also: -setTitleCell:

### titleColor

- (NSColor*) titleColor;
Availability: OpenStep

Returns the colour used to draw the title.

See Also: -setTitleColor:

### titleFont

- (NSFont*) titleFont;
Availability: OpenStep

Returns the font used to draw the title.

See Also: -setTitleFont:

Up