Up

# NSControl

### Authors

Scott Christley (`scottc@net-community.com`)
Richard Frith-Macdonald (`richard@brainstorm.co.uk`)

> The abstract control class

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

### Contents -

1. Software documentation for the NSControl class
2. Software documentation for the NSObject(NSControlDelegate) informal protocol
3. Software documentation for the NSObject(NSControlTextEditingDelegate) informal protocol
4. Software documentation for the NSControlTextEditingDelegate protocol

# Software documentation for the NSControl class

## NSControl : NSView

> Declared in:
>   AppKit/NSControl.h

Availability: OpenStep

TODO Description

Instance Variables
Method summary

- +cellClass
- +setCellClass:
- -abortEditing
- -action
- -alignment
- -attributedStringValue
- -baseWritingDirection
- -calcSize
- -cell
- -currentEditor
- -doubleValue
- -drawCell:
- -drawCellInside:
- -floatValue
- -font
- -formatter
- -ignoresMultiClick
- -intValue
- -integerValue
- -isContinuous
- -isEnabled
- -mouseDown:
- -objectValue
- -performClick:
- -refusesFirstResponder
- -selectCell:
- -selectedCell
- -selectedTag
- -sendAction:to:
- -sendActionOn:
- -setAction:
- -setAlignment:
- -setAttributedStringValue:
- -setBaseWritingDirection:
- -setCell:
- -setContinuous:
- -setDoubleValue:
- -setEnabled:
- -setFloatValue:
- -setFloatingPointFormat:left:right:
- -setFont:
- -setFormatter:
- -setIgnoresMultiClick:
- -setIntValue:
- -setIntegerValue:
- -setNeedsDisplay
- -setObjectValue:
- -setRefusesFirstResponder:
- -setStringValue:
- -setTag:
- -setTarget:
- -sizeThatFits:
- -sizeToFit
- -stringValue
- -tag
- -takeDoubleValueFrom:
- -takeFloatValueFrom:
- -takeIntValueFrom:
- -takeIntegerValueFrom:
- -takeObjectValueFrom:
- -takeStringValueFrom:
- -target
- -updateCell:
- -updateCellInside:
- -validateEditing

### cellClass

+ (Class) cellClass;
Availability: OpenStep

Returns the cell Class used by NSControl. Used by subclasses.

See Also: +setCellClass:

### setCellClass:

+ (void) setCellClass: (Class)factoryId;
Availability: OpenStep

Sets the cell Class used by NSControl to factoryId. Used by subclasses.

See Also: +setCellClass:

### abortEditing

- (BOOL) abortEditing;
Availability: OpenStep

Sends an [NSCell -endEditing:] message to the current object used to edit the NSControl. Returns `NO` if the the currentEditor does not exists, `YES` otherwise.

### action

- (SEL) action;
Availability: OpenStep

Returns the NSControl's cell action method.

See Also: -setAction: [NSCell -action]

### alignment

- (NSTextAlignment) alignment;
Availability: OpenStep

Returns the alignment of the text in the NSControl's cell. Returns NSNaturalTextAlignment if the cell does not exists. See NSTextAlignment for more informations.

See Also: -setAlignment: [NSCell -alignment]

### attributedStringValue

- (NSAttributedString*) attributedStringValue;
Availability: MacOS-X 10.0.0
Description forthcoming.

### baseWritingDirection

- (NSWritingDirection) baseWritingDirection;
Availability: MacOS-X 10.4.0
Description forthcoming.

### calcSize

- (void) calcSize;
Availability: OpenStep

Recalculates the internal size by sending [NSCell -calcDrawInfo:] to the cell.

### cell

- (id) cell;
Availability: OpenStep

Returns the NSControl's cell.

See Also: -setCell:

### currentEditor

- (NSText*) currentEditor;
Availability: OpenStep

Returns the NSText object used when editing the NSControl.

### doubleValue

- (double) doubleValue;
Availability: OpenStep

Returns the value of the NSControl's selected cell as double.

See Also: -setDoubleValue: [NSCell -doubleValue] -intValue -floatValue -doubleValue -stringValue

### drawCell:

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

Redraws a aCell if it is the NSControl's cell.

See Also: -setCell: [NSCell -drawWithFrame:inView:]

### drawCellInside:

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

Redraws a aCell 's inside if it is the NSControl's cell.

See Also: -setCell: [NSCell -drawInteriorWithFrame:inView:]

### floatValue

- (float) floatValue;
Availability: OpenStep

Returns the value of the NSControl's selected cell as float.

See Also: -setFloatValue: [NSCell -floatValue] -intValue -stringValue -doubleValue

### font

- (NSFont*) font;
Availability: OpenStep

Returns the font of the text in the NSControl's cell. Returns `nil` if the cell does not exists.

See Also: -setFont: [NSCell -font]

### formatter

- (id) formatter;
Availability: MacOS-X 10.0.0
Description forthcoming.

### ignoresMultiClick

- (BOOL) ignoresMultiClick;
Availability: OpenStep

Returns wheter multiple clicks are ignored.

See Also: -setIgnoresMultiClick: -mouseDown:

### intValue

- (int) intValue;
Availability: OpenStep

Returns the value of the NSControl's selected cell as int.

See Also: -setIntValue: [NSCell -intValue] -floatValue -doubleValue -stringValue

### integerValue

- (NSInteger) integerValue;
Availability: MacOS-X 10.5.0

Returns the value of the NSControl's selected cell as int.

See Also: -setIntegerValue: [NSCell -integerValue] -floatValue -doubleValue -stringValue

### isContinuous

- (BOOL) isContinuous;
Availability: OpenStep

Returns whether the NSControl's cell can continuously sends its action message.

See Also: -setContinuous: [NSCell -isContinuous]

### isEnabled

- (BOOL) isEnabled;
Availability: OpenStep

Returns whether the selected cell of the NSControl is enabled.

See Also: -setEnabled: [NSCell -isEnabled]

### mouseDown:

- (void) mouseDown: (NSEvent*)theEvent;
Availability: OpenStep
Description forthcoming.

### objectValue

- (id) objectValue;
Availability: OpenStep
Description forthcoming.

### performClick:

- (void) performClick: (id)sender;
Availability: OpenStep
Simulates a single mouse click on the control. This method calls the cell's method performClickWithFrame:inView:. Take note that sender is not used.

### refusesFirstResponder

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

### selectCell:

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

Sets the aCell's state to NSOnState and marks self for display if it is the NSControl's cell.

### selectedCell

- (id) selectedCell;
Availability: OpenStep

Returns the NSControl's selected cell.

### selectedTag

- (NSInteger) selectedTag;
Availability: OpenStep

Returns the tag of the NSControl's selected cell (if exists). -1 otherwise.

See Also: [NSCell -tag]

### sendAction: to:

- (BOOL) sendAction: (SEL)theAction to: (id)theTarget;
Availability: OpenStep

Asks the NSApplication to send an action theAction with theTarget as target to NSControl. Returns `NO` if theAction is `nil` or if NSApplication can not send the action.

See Also: [NSApplication -sendAction:to:from:]

### sendActionOn:

- (NSInteger) sendActionOn: (NSInteger)mask;
Availability: OpenStep
Description forthcoming.

### setAction:

- (void) setAction: (SEL)aSelector;
Availability: OpenStep

Sets the NSControl's cell action method.

See Also: -action [NSCell -setAction:]

### setAlignment:

- (void) setAlignment: (NSTextAlignment)mode;
Availability: OpenStep

Sets the alignment of the text in the NSControl's cell to mode. This method abort the editing and marks self for display if the cell is an NSActionCell. See NSTextAlignment for more informations.

See Also: -alignment [NSCell -setAlignment:] -abortEditing

### setAttributedStringValue:

- (void) setAttributedStringValue: (NSAttributedString*)attribStr;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setBaseWritingDirection:

- (void) setBaseWritingDirection: (NSWritingDirection)direction;
Availability: MacOS-X 10.4.0
Description forthcoming.

### setCell:

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

Sets the NSControl's cell to aCell, Raises an NSInvalidArgumentException exception if aCell is not `nil` and if it is not a cell class.

See Also: -cell

### setContinuous:

- (void) setContinuous: (BOOL)flag;
Availability: OpenStep

Sets whether the NSControl's cell can continuously sends its action message.

See Also: -isContinuous [NSCell -setContinuous:]

### setDoubleValue:

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

Sets the value of the NSControl's selected cell to double. If the selected cell is an action cell, it marks self for display.

See Also: -doubleValue [NSCell -setDoubleValue:] -setIntValue: -setStringValue: -setFloatValue:

### setEnabled:

- (void) setEnabled: (BOOL)flag;
Availability: OpenStep

Sets whether the NSControl's selected cell is enabled. If flag is `NO`, this method abort the editing. This method marks self for display.

See Also: -isEnabled [NSCell -setEnabled:]

### setFloatValue:

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

Sets the value of the NSControl's selected cell to float. If the selected cell is an action cell, it marks self for display.

See Also: -floatValue [NSCell -setFloatValue:] -setIntValue: -setStringValue: -setDoubleValue:

### setFloatingPointFormat: left: right:

- (void) setFloatingPointFormat: (BOOL)autoRange left: (NSUInteger)leftDigits right: (NSUInteger)rightDigits;
Availability: OpenStep
Description forthcoming.

### setFont:

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

Sets the font of the text in the NSControl's cell and the editor object (if exists) to fontObject.

See Also: -font [NSCell -setFont:] -currentEditor

### setFormatter:

- (void) setFormatter: (NSFormatter*)newFormatter;
Availability: MacOS-X 10.0.0
Description forthcoming.

### setIgnoresMultiClick:

- (void) setIgnoresMultiClick: (BOOL)flag;
Availability: OpenStep

Sets wheter multiple clicks are ignored.

See Also: -ignoresMultiClick -mouseDown:

### setIntValue:

- (void) setIntValue: (int)anInt;
Availability: OpenStep

Sets the value of the NSControl's selected cell to int. If the selected cell is an action cell, it marks self for display.

See Also: -intValue [NSCell -setIntValue:] -setDoubleValue: -setFloatValue: -setStringValue:

### setIntegerValue:

- (void) setIntegerValue: (NSInteger)anInt;
Availability: MacOS-X 10.5.0

Sets the value of the NSControl's selected cell to int. If the selected cell is an action cell, it marks self for display.

See Also: -integerValue [NSCell -setIntegerValue:] -setDoubleValue: -setFloatValue: -setStringValue:

### setNeedsDisplay

- (void) setNeedsDisplay;
Availability: OpenStep

Marks self for display.

### setObjectValue:

- (void) setObjectValue: (id)anObject;
Availability: OpenStep
Description forthcoming.

### setRefusesFirstResponder:

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

### setStringValue:

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

Sets the value of the NSControl's selected cell to NSString. If the selected cell is an action cell, it marks self for display.

See Also: -stringValue [NSCell -setStringValue:] -setIntValue: -setFloatValue: -setDoubleValue:

### setTag:

- (void) setTag: (NSInteger)anInt;
Availability: OpenStep
Assigning a Tag

### setTarget:

- (void) setTarget: (id)anObject;
Availability: OpenStep

Sets the target object of the NSControl's cell to anObject.

See Also: -target [NSCell -setTarget:]

### sizeThatFits:

- (NSSize) sizeThatFits: (NSSize)size;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.

### sizeToFit

- (void) sizeToFit;
Availability: OpenStep

Resizes the NSControl to fits the NSControl's cell size.

See Also: [NSCell -cellSize]

### stringValue

- (NSString*) stringValue;
Availability: OpenStep

Returns the value of the NSControl's selected cell as NSString.

See Also: -setStringValue: [NSCell -stringValue] -intValue -floatValue -doubleValue -stringValue

### tag

- (NSInteger) tag;
Availability: OpenStep

Returns the NSControl tag

See Also: -setTag:

### takeDoubleValueFrom:

- (void) takeDoubleValueFrom: (id)sender;
Availability: OpenStep

Sets the NSControl's selected cell to the sender's double value.

See Also: [NSCell -takeDoubleValueFrom:] -takeFloatValueFrom: takeIntValueFrom: takeStringValueFrom:

### takeFloatValueFrom:

- (void) takeFloatValueFrom: (id)sender;
Availability: OpenStep

Sets the NSControl's selected cell to the sender's float value.

See Also: [NSCell -takeDoubleValueFrom:] -takeDoubleValueFrom: -takeIntValueFrom: -takeStringValueFrom:

### takeIntValueFrom:

- (void) takeIntValueFrom: (id)sender;
Availability: OpenStep

Sets the NSControl's selected cell to the sender's float int.

See Also: [NSCell -takeIntValueFrom:] -takeDoubleValueFrom: -takeFloatValueFrom: -takeStringValueFrom:

### takeIntegerValueFrom:

- (void) takeIntegerValueFrom: (id)sender;
Availability: MacOS-X 10.5.0

Sets the NSControl's selected cell to the sender's float int.

See Also: [NSCell -takeIntegerValueFrom:] -takeDoubleValueFrom: -takeFloatValueFrom: -takeStringValueFrom:

### takeObjectValueFrom:

- (void) takeObjectValueFrom: (id)sender;
Availability: OpenStep
Description forthcoming.

### takeStringValueFrom:

- (void) takeStringValueFrom: (id)sender;
Availability: OpenStep

Sets the NSControl's selected cell to the sender's float int.

See Also: [NSCell -takeDoubleValueFrom:] -takeDoubleValueFrom: -takeFloatValueFrom: -takeIntValueFrom:

### target

- (id) target;
Availability: OpenStep

Returns the target object of the NSControl's cell.

See Also: -setTarget: [NSCell -target]

### updateCell:

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

Marks self for display.

### updateCellInside:

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

Marks self for display.

### validateEditing

- (void) validateEditing;
Availability: OpenStep
Description forthcoming.

## Instance Variables for NSControl Class

### _cell

@protected id _cell;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _ignoresMultiClick

@protected BOOL _ignoresMultiClick;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

### _tag

@protected NSInteger _tag;
Availability: OpenStep
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.

# Software documentation for the NSObject(NSControlDelegate) informal protocol

## NSObject(NSControlDelegate)

> Declared in:
>   AppKit/NSControl.h

Availability: OpenStep
Description forthcoming.
Method summary

- -controlTextDidBeginEditing:
- -controlTextDidChange:
- -controlTextDidEndEditing:

### controlTextDidBeginEditing:

- (void) controlTextDidBeginEditing: (NSNotification*)aNotification;
Availability: OpenStep
Description forthcoming.

### controlTextDidChange:

- (void) controlTextDidChange: (NSNotification*)aNotification;
Availability: OpenStep
Description forthcoming.

### controlTextDidEndEditing:

- (void) controlTextDidEndEditing: (NSNotification*)aNotification;
Availability: OpenStep
Description forthcoming.

# Software documentation for the NSObject(NSControlTextEditingDelegate) informal protocol

## NSObject(NSControlTextEditingDelegate)

> Declared in:
>   AppKit/NSControl.h

Availability: OpenStep
Description forthcoming.
Method summary

- -control:didFailToFormatString:errorDescription:
- -control:didFailToValidatePartialString:errorDescription:
- -control:isValidObject:
- -control:textShouldBeginEditing:
- -control:textShouldEndEditing:
- -control:textView:completions:forPartialWordRange:indexOfSelectedItem:
- -control:textView:doCommandBySelector:

### control: didFailToFormatString: errorDescription:

- (BOOL) control: (NSControl*)control didFailToFormatString: (NSString*)string errorDescription: (NSString*)error;
Availability: OpenStep
Description forthcoming.

### control: didFailToValidatePartialString: errorDescription:

- (void) control: (NSControl*)control didFailToValidatePartialString: (NSString*)string errorDescription: (NSString*)error;
Availability: OpenStep
Description forthcoming.

### control: isValidObject:

- (BOOL) control: (NSControl*)control isValidObject: (id)object;
Availability: OpenStep
Description forthcoming.

### control: textShouldBeginEditing:

- (BOOL) control: (NSControl*)control textShouldBeginEditing: (NSText*)fieldEditor;
Availability: OpenStep
Description forthcoming.

### control: textShouldEndEditing:

- (BOOL) control: (NSControl*)control textShouldEndEditing: (NSText*)fieldEditor;
Availability: OpenStep
Description forthcoming.

### control: textView: completions: forPartialWordRange: indexOfSelectedItem:

- (NSArray*) control: (NSControl*)control textView: (NSTextView*)textView completions: (NSArray*)words forPartialWordRange: (NSRange)charRange indexOfSelectedItem: (int*)index;
Availability: MacOS-X 10.0.0
Description forthcoming.

### control: textView: doCommandBySelector:

- (BOOL) control: (NSControl*)control textView: (NSTextView*)textView doCommandBySelector: (SEL)command;
Availability: MacOS-X 10.0.0
Description forthcoming.

# Software documentation for the NSControlTextEditingDelegate protocol

## NSControlTextEditingDelegate

> Declared in:
>   AppKit/NSControl.h

> Conforms to:
>   NSObject

Availability: OpenStep
Description forthcoming.
Up