Working with menu items outside the model in NSPopUpButton

It is trivial to configure the NSPopUpButton menu through binding to NSArrayController. A somewhat more complicated, but very frequent use case is to use NSContentPlacementTagBindingOptionto insert array elements into the menu from the specified index. A good example of this is given below, NSPopUpButton + Bindings + Show all options .

For example, let's say I have the following user interface that uses a popup to select a column from a table view. Since the column can be added and deleted dynamically by the user, menu items must be synchronized with the model,

                       _________________
Select table column:  |____None_________|   <--- this is the popup

The menu may contain the following items:

_______________
|    None     |   <-- Out of model item, "None" or empty selection
 -------------    <-- Out of model item, separator item
|  column 1   |   <-- These are dynamically replaced menu
|  column 2   |       item done using bindings and the
|  column 3   |       NSContentPlacementTagBindingOption
|_____________|       option from IB.

, , IB , . , . , , : "" . , . , selected object .

- NSContentPlacementTagBindingOption, NSPopUpButton () ?

, .

NSPopUpButton : ( ), , . .

+4

All Articles