EOPopUpAssociation

Inherits From:
EOAssociation : EODelayedObserver : NSObject

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

Declared in: EOInterface/EOPopUpAssociation.h

Class At a Glance:

Purpose

An EOPopUpAssociation displays a single attribute or to-one relationship value from a list of possible values. The titles aspect is typically bound to an attribute of the destination entity's EODisplayGroup, and one of the selectedTitle , selectedTag , or selectedObject aspects is bound to the source entity's EODisplayGroup.

Usable With

NSPopUpButton

Aspects

titles
An attribute of the objects in an EODisplayGroup whose values can be represented as strings.
selectedTitle
An attribute of the selected object whose values can be represented as strings.
selectedTag
An integer attribute of the selected object.
selectedObject
A to-one relationship of the selected object; the value displayed is that for the attribute bound to the titles aspect.
enabled
A boolean attribute of the selected object, which determines whether the NSPopUpButton is enabled.

Object Keys Taken

target
When the user chooses an item in the pop-up list, the EOPopUpAssociation updates the selected object's property with the item's title, tag, or object.

Class Description

EOPopUpAssociation displays an attribute or to-one relationship value in an NSPopUpButton. The items in the NSPopUpButton can be entered manually, or for a relationship, constructed dynamically from values supplied by the destination entity's EODisplayGroup. The value displayed by the NSPopUpButton can be bound by one of three aspects: selectedTitle , which is useful for values representable as strings; selectedTag , for integer values; and selectedObject , for the destination object of a relationship.

Examples

Selecting a string from a static list: Given an EODisplayGroup of Movies, the goal is to provide a pop-up list for setting the rating. Assume the rating is a string property of the Movie object rather than a relationship to a Rating object. In this case you type the list of ratings into the pop-up list in Interface Builder, and then bind the selectedTitle aspect to the "rating" property of the Movie EODisplayGroup. If an object's string attribute value isn't in the pop-up list, it's temporarily added while the object is selected.

Selecting a string from a dynamic list: As above, but we want to fill the popup from the "ratingString" property of an EODisplayGroup containing an array of Rating objects fetched from an external source. In this case you bind the titles aspect to the "ratingString" property of the Ratings EODisplayGroup, and bind the selectedTitle aspect to the "rating" property of the Movie EODisplayGroup.

Selecting an integer tag from a static list: Given an EODisplayGroup of customers, whose credit card type is indicated by a tag, the goal is to provide the credit card name on the pop-up list (Visa, MasterCard, and so on). In this case you set the credit card names and tags for the pop-up list in Interface Builder, and then bind the selectedTag aspect to the "cardType" property of the Customer EODisplayGroup. You can also allow for a general "other" value by defining a special tag and setting it in the EOPopUpAssociation using setTagValueForOther: . Credit card tags from the database not matching any in the pop-up list are then displayed as the "other" value. (It would also make sense to disable the pop-up list in this case, to avoid writing the meaningless tag back to the database.)

Selecting an object to assign to a to-one relationship: Given a list of employees, the goal is to assign the department each employee belongs to. In terms of the object model, we want to assign a Department object to the "department" property of an Employee object. In this case you bind the titles aspect to the "name" property of a Department EODisplayGroup, and bind the selectedObject aspect to the "department" relationship property of the Employee EODisplayGroup. This fills the pop-up list with the names of departments, and causes the name of the selected Employee's Department to be selected in the pop-up list.

Instance Methods

setTagValueForOther:

- (void)setTagValueForOther: (int)tag

Records tag as the "unknown" tag. When a property value doesn't match any other tag in the pop-up list, the EOPopUpAssociation automatically selects the item for this tag. If there's no item for this tag, the pop-up list's selection isn't changed. This tag value is by default -1.

tagValueForOther

- (int)tagValueForOther

Returns the "unknown" tag. When a property value doesn't match any other tag in the pop-up list, the EOPopUpAssociation automatically selects the item for this tag. If there's no item for this tag, the pop-up list's selection isn't changed. This tag value is by default -1.

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