Up

NSComboBox

Authors

Gerrit van Dyk (gerritvd@decillion.net)

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


Contents -

  1. Class Description
  2. Software documentation for the NSObject(NSComboBoxDataSource) informal protocol
  3. Software documentation for the NSObject(NSComboBoxNotifications) informal protocol

Class Description

An NSComboBox is what we can call a completion/choices box, derived from NSTextField, it allows you to enter text like in a text field but also to click in the ellipsis button (indicating the fact other user inputs are possible) on the right of it to obtain a list of choices, you can use them as the text field value by selecting a row in this list. You can also obtain direct completion when it is enabled via setCompletes: to get a suggested text field value updated as you type.

Like other NSControl classes, NSComboBox is a wrapper around a core piece which implements the combo box behavior, a cell, which is in this case an NSComboBoxCell.

NSComboBox : NSTextField

Declared in:
AppKit/NSComboBox.h
Availability: Not in OpenStep/MacOS-X


No special instructions to use NSComboBox or text to detail the implementation.

Method summary

addItemWithObjectValue: 

- (void) addItemWithObjectValue: (id)object;
Availability: Not in OpenStep/MacOS-X

Adds an item to the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES , this method logs a warning.


addItemsWithObjectValues: 

- (void) addItemsWithObjectValues: (NSArray*)objects;
Availability: Not in OpenStep/MacOS-X

Adds several items in an array to the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES, this method logs a warning.


completes 

- (BOOL) completes;
Availability: Not in OpenStep/MacOS-X

Returns YES when the combo box cell automatic completion is active, returns NO otherwise. Take a look at the setCompletes: method documentation to know how the automatic completion works.


dataSource 

- (id) dataSource;
Availability: Not in OpenStep/MacOS-X

Returns the combo box cell data source object which is reponsible to provide the data to be displayed. To know how to implement a data source object, take a look at the NSComboBoxDataSource informal protocol description. In the case usesDataSource returns NO, this method logs a warning.


deselectItemAtIndex: 

- (void) deselectItemAtIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Deselects the combo box cell list row at index in the case this row is selected. Posts an NSComboBoxSelectionDidChangeNotification to the default notification center, when there is a new selection.


hasVerticalScroller 

- (BOOL) hasVerticalScroller;
Availability: Not in OpenStep/MacOS-X

Returns YES when the combo box cell displays a vertical scroller for its list, returns NO otherwise. Take note that the scroller will be displayed even when the sum of the items height in the list is inferior to the minimal height of the list displayed area.


indexOfItemWithObjectValue: 

- (int) indexOfItemWithObjectValue: (id)object;
Availability: Not in OpenStep/MacOS-X

Returns the lowest index associated with a value in the combo box cell default items list, which is equal to object, and returns NSNotFound when there is no such value. In the case usesDataSource returns YES , this method logs a warning.


indexOfSelectedItem 

- (int) indexOfSelectedItem;
Availability: Not in OpenStep/MacOS-X

Returns the index of the selected item in the combo box cell list or -1 when there is no selection, the selected item can be related to the data source object in the case usesDataSource returns YES else to the default items list.


insertItemWithObjectValue: atIndex: 

- (void) insertItemWithObjectValue: (id)object atIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Inserts an item in the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES , this method logs a warning.


intercellSpacing 

- (NSSize) intercellSpacing;
Availability: Not in OpenStep/MacOS-X

Returns the width and the height (as the values of an NSSize variable) between each item of the combo box cell list.


itemHeight 

- (float) itemHeight;
Availability: Not in OpenStep/MacOS-X

Returns the height of the items in the combo box cell list.


itemObjectValueAtIndex: 

- (id) itemObjectValueAtIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Returns the object value at index within combo box cell default items list. When the index is beyond the end of the list, an NSRangeException is raised. In the case usesDataSource returns YES , this method logs a warning.


noteNumberOfItemsChanged 

- (void) noteNumberOfItemsChanged;
Availability: Not in OpenStep/MacOS-X

Informs the combo box cell that the number of items in its data source has changed, in order to permit to the scrollers in its displayed list being updated without needing the reload of the data. It is recommended to use this method with a data source that continually receives data in the background, to keep the the combo box cell responsive to the user while the data is received. Take a look at the NSComboBoxDataSource informal protocol specification to know more on the messages NSComboBox sends to its data source.


numberOfItems 

- (int) numberOfItems;
Availability: Not in OpenStep/MacOS-X

Returns the number of items in the the combo box cell list, the numbers of items can be be related to the data source object in the case usesDataSource returns YES else to the default items list.


numberOfVisibleItems 

- (int) numberOfVisibleItems;
Availability: Not in OpenStep/MacOS-X

Returns the maximum number of allowed items to be displayed in the combo box cell list.


objectValueOfSelectedItem 

- (id) objectValueOfSelectedItem;
Availability: Not in OpenStep/MacOS-X

Returns the object value of the selected item in the combo box cell default items list or nil when there is no selection. In the case usesDataSource returns YES, this method logs a warning.


objectValues 

- (NSArray*) objectValues;
Availability: Not in OpenStep/MacOS-X

Returns the combo box cell default items list in an array.


reloadData 

- (void) reloadData;
Availability: Not in OpenStep/MacOS-X

Marks the combo box cell in order to have its items list reloaded in the case it uses a data source, and to have it redisplayed.


removeAllItems 

- (void) removeAllItems;
Availability: Not in OpenStep/MacOS-X

Removes all the items in the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES, this method logs a warning.


removeItemAtIndex: 

- (void) removeItemAtIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Removes the item with the specified index in the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES , this method logs a warning.


removeItemWithObjectValue: 

- (void) removeItemWithObjectValue: (id)object;
Availability: Not in OpenStep/MacOS-X

Removes an item in the combo box cell default items list which is used when usesDataSource returns NO. In the case usesDataSource returns YES , this method logs a warning.


scrollItemAtIndexToTop: 

- (void) scrollItemAtIndexToTop: (int)index;
Availability: Not in OpenStep/MacOS-X

Scrolls the combo box cell list vertically in order to have the item at index in the closest position relative to the top. There is no need to have the list displayed when this method is invoked.


scrollItemAtIndexToVisible: 

- (void) scrollItemAtIndexToVisible: (int)index;
Availability: Not in OpenStep/MacOS-X

Scrolls the combo box cell list vertically in order to have the item at index visible. There is no need to have the list displayed when this method is invoked.


selectItemAtIndex: 

- (void) selectItemAtIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Selects the combo box cell list row at index. Take note no changes occurs in the combo box cell list when this method is called. Posts an NSComboBoxSelectionDidChangeNotification to the default notification center when there is a new selection different from the previous one.


selectItemWithObjectValue: 

- (void) selectItemWithObjectValue: (id)object;
Availability: Not in OpenStep/MacOS-X

Selects the first item in the default combo box cell list which is equal to object. In the case usesDataSource returns YES, this method logs a warning. Take note that this method doesn't update the text field part value. Posts an NSComboBoxSelectionDidChange notification to the default notification center when the new selection is different than the previous one.


setCompletes: 

- (void) setCompletes: (BOOL)completes;
Availability: Not in OpenStep/MacOS-X

Sets whether the combo box cell automatic completion is active or not. The automatic completion tries to complete what the user types in the text field part, it tries to complete only when the the user adds characters at the end of the string, not when it deletes characters or when the insertion point precedes the end of the string. To do the automatic completion, the completedString: method is called, and when the returned string is longer than the current one in the text field, the completion occurs and the completed part gets selected.


setDataSource: 

- (void) setDataSource: (id)aSource;
Availability: Not in OpenStep/MacOS-X

Sets the combo box cell data source to aSource. Just calling this method doesn't set usesDataSource to return YES, you must call setUsesDataSource: with YES before or a warning will be logged. To know how to implement a data source objects, take a look at the NSComboBoxDataSource informal protocol description. When aSource doesn't respond to the methods numberOfItemsInComboBox: comboBox:objectValueForItemAtIndex:, this method logs a warning.


setHasVerticalScroller: 

- (void) setHasVerticalScroller: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X

Sets whether the combo box cell list displays a vertical scroller, by default it is the case. When flag is NO and the combo cell list has more items (either in its default list or from its data source) than the number returned by numberOfVisibleItems, only a subset of them will be displayed. Uses scroll related methods to position this subset in the combo box cell list. Take note that the scroller will be displayed even when the sum of the items height in the list is inferior to the minimal height of the list displayed area.


setIntercellSpacing: 

- (void) setIntercellSpacing: (NSSize)aSize;
Availability: Not in OpenStep/MacOS-X

Sets the width and the height between each item of the combo box cell list to the values in aSize .


setItemHeight: 

- (void) setItemHeight: (float)itemHeight;
Availability: Not in OpenStep/MacOS-X

Sets the height of the items in the combo box cell list to itemHeight.


setNumberOfVisibleItems: 

- (void) setNumberOfVisibleItems: (int)visibleItems;
Availability: Not in OpenStep/MacOS-X

Sets the maximum number of allowed items to be displayed in the combo box cell list.


setUsesDataSource: 

- (void) setUsesDataSource: (BOOL)flag;
Availability: Not in OpenStep/MacOS-X

Sets according to flag whether the combo box cell uses a data source (which is external) to populate its items list.


usesDataSource 

- (BOOL) usesDataSource;
Availability: Not in OpenStep/MacOS-X

Returns YES when the combo box cell uses a data source (which is external) to populate its items list, otherwise returns NO in the case it uses its default list.


Software documentation for the NSObject(NSComboBoxDataSource) informal protocol

NSObject(NSComboBoxDataSource)

Declared in:
AppKit/NSComboBox.h
Availability: Not in OpenStep/MacOS-X

Description forthcoming.

Method summary

comboBox: completedString: 

- (NSString*) comboBox: (NSComboBox*)aComboBox completedString: (NSString*)aString;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


comboBox: indexOfItemWithStringValue: 

- (unsigned int) comboBox: (NSComboBox*)aComboBox indexOfItemWithStringValue: (NSString*)string;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


comboBox: objectValueForItemAtIndex: 

- (id) comboBox: (NSComboBox*)aComboBox objectValueForItemAtIndex: (int)index;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


numberOfItemsInComboBox: 

- (int) numberOfItemsInComboBox: (NSComboBox*)aComboBox;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


Software documentation for the NSObject(NSComboBoxNotifications) informal protocol

NSObject(NSComboBoxNotifications)

Declared in:
AppKit/NSComboBox.h
Availability: Not in OpenStep/MacOS-X

Description forthcoming.

Method summary

comboBoxSelectionDidChange: 

- (void) comboBoxSelectionDidChange: (NSNotification*)notification;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


comboBoxSelectionIsChanging: 

- (void) comboBoxSelectionIsChanging: (NSNotification*)notification;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


comboBoxWillDismiss: 

- (void) comboBoxWillDismiss: (NSNotification*)notification;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.


comboBoxWillPopUp: 

- (void) comboBoxWillPopUp: (NSNotification*)notification;
Availability: Not in OpenStep/MacOS-X

Description forthcoming.



Up