EOControlAssociation

Inherits From:
EOGenericControlAssociation : EOAssociation : EODelayedObserver : NSObject

Conforms To: NSCoding (EOAssociation)
EOObserving (EODelayedObserver)
NSObject (NSObject)

Declared in: EOInterface/EOControlAssociation.h

Class At a Glance:

Purpose

An EOControlAssociation displays a single attribute value in its display object (an NSControl) and updates that value in the selected object when the NSControl changes.

Usable With

Any NSControl

Aspects

value
An attribute of the selected object, displayed in the NSControl.
enabled
A boolean attribute of the selected object, which determines whether the NSControl is enabled.

Object Keys Taken

target
On receiving an action message from the NSControl, an EOControlAssociation sends the NSControl's value to the EODisplayGroup.
delegate
An EOControlAssociation accepts messages related to editing and validation of text, such as control:textShouldBeginEditing: and control:didFailToFormatString:errorDescription: .

Class Description

EOControlAssociation is the default EOAssociation subclass for use with NSControls. An EOControlAssociation displays the value of the selected object in its NSControl, and updates the object when the NSControl's value changes. A sibling class, EOActionCellAssociation, can be used with individual cells in an NSMatrix or NSForm. Some other subclasses of EOAssociation, such as EOPopUpAssociation and EOColumnAssociation, supersede these classes for more specialized behavior.

EOControlAssociations access values using NSControl's setObjectValue: method, which allows values with non-string representations to be displayed. An EOControlAssociation can be bound to an NSImageView, for example, with an attribute whose class is NSImage.

Examples

To display a movie's budget in an NSTextField, create an EOControlAssociation to the Movie display group and bind the value aspect to the "budget" key. If the NSTextField is editable, then when the user types a new value and presses Enter or Tab, the selected movie's budget attribute is changed.

Assuming that Movie objects implement an isBudgetNegotiable method, you can make the NSTextField uneditable depending on the selected movie. To do so, add an "isBudgetNegotiable" key to the Movie display group in Interface Builder and bind the the "enabled" key to it.

Instance Methods

control

- (NSControl *)control

Returns the receiver's control object (for EOControlAssociation this method is equivalent to EOAssociation's object method).

editingAssociation

- (EOGenericControlAssociation *)editingAssociation

Returns self .

Copyright © 1997, Apple Computer, Inc. All rights reserved.