====== Combo Boxes ====== {{tag>actionstep documentation}} A combo box, otherwise known in the Aqua docs as a "combination box" are useful to display a limited set of data from which the user can choose from. ===== Related Classes ===== * ''org.actionstep.NSComboBox'' * ''org.actionstep.NSComboBoxCell'' * ''org.actionstep.NSComboBoxCellDataSource'' * ''org.actionstep.NSComboBoxCellSearchingDataSource'' ===== Adding Entries ===== FIXME ===== Parsing Behaviour of Added Entries ===== When a list of objects is passed to ''addItemsWithObjectValues'', ''addItemWithObjectValue'' or any such variants, a label/datum will be created from the object ("entry"). Please note that the terms "label" and "data" will be used interchangably, since the control will not distinguish between them. If the entry is not of type ''String'', then it will be cast to one, invoking ''toString()'' in the process. ==== Use Case ==== Developers familiar with MM's equivalent component will most probably have worked with the label-data format. However, NSComboBox does not support this. Thus you will have to maintain 2 separate sets of data: * one for labels, and * another for the corresponding data. For example, you could create a hash containing the labels and data, and add the labels as entries to the combo box: var myCb:NSComboBox = (new NSComboBox()).initWithFrame(new NSRect(10, 10, 150, 30)); //remember to add the combobox to a view //you could, of course, use a better //method of instantiation. var data:NSDictionary = NSDictionary.dictionaryWithObjectsAndKeys( "data for Rich", "Rich", "data for Tom", "Tom", "data for John", "John"); myCb.addItemsWithObjectValues(data.allKeys()); myCb.setAction("comboBoxChanged"); myCb.setTarget({ comboBoxChanged: function(c:NSComboBox):Void { trace("selected data: "+data.objectForKey( c.objectValueOfSelectedItem() )); }});