It is trivial to setup NSPopUpButton's menu via binding with an NSArrayController. A slightly more complicated, but very frequent use case, is to use NSContentPlacementTagBindingOption to insert the array items into the menu from a specified index. A nice example of this is given here, NSPopUpButton + Bindings + Show All Option.
For example, say I have, the following UI which uses a popup to select a column from a table view. Because the column can be added and removed dynamically by the user the menu items need to be synchronised with model,
_________________
Select table column: |____None_________| <--- this is the popup
The menu could have 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.
Notice that there are two non-model-items in the menu, they are inserted into the UI in IB before the the content replaced tag. Using the content replacement tag massively simplifies populating the menu and keeping the items synchronised with the model. However, this causes huge problems when the uses makes a selection which is outside the content of the bound array: the "None" marker and the the separator item. Because they are outside the array they cannot become selected items. So the popup button's selected object binding cannot be use to track selection changes from UI to model.
Has anybody found a successful way of working with NSContentPlacementTagBindingOption, NSPopUpButton and non-model (static) items in the menu?
I'm pretty much about ready to give up and populate the menu manually, which would suck.
NSPopUpButton needs to accept two array controllers: one for static content (the none and separator) and the one for dynamic content which works with content replacement tags. This would make all choices valid.
Related
There are many outline items (menus) and many views and forms in the current running system.
The view is actually the same content, but the conditions are different.
Is there a way to have only one view and set conditions in the outer frame to display the content of the view?
for example:
There are 3 outer frame items (menu), click any outer frame item, a view will be displayed.
Menu 1 will open the view sorted by name
Menu 2 will open the view sorted by serial number
Menu 3 will open the view sorted by date
The views are all the same content, but different sorting methods are set to display.
As in the example, because there are 3 sorting methods, there are 3 views.
Is there a way to become only one view?
You can't control sorting. If you look at the NotesUIView class, you'll see there are no methods available for that. There's not much available there at all.
The only way you can control a view from code outside the view is by embedding it in a form, subform, or page, and using the Show Single Category feature.
I am toying with Base but am stuck on how to set the ListSource of a ListBox with an array of values rather than data from a query.
Any help would be appreciated.
To add entries manually, edit the form and create a new list box. Right-click on the control and choose Control. At General tab of control properties window, edit List entries property: add the first item, press Shift+Enter, and then add another item.
From How to Programmatically add or remove items in ListBox FORM control, #Lyrl writes:
The listbox array content is clunky; it's actually easier to work with if the form is connected to a Base file and the listbox content is determined by an SQL string.
That page also shows macro code to populate the list with an array of values.
oListBox.StringItemList() = Array("One", "Two", "Three")
Here's my situation. I have a main grid, where each row expands to show 2 tabs. The first tab has another grid, with dynamically columns. One of the columns needs to display a template with a modified Kendo Menu (in order for it to look like a dropdown).
When the column is rendered in the main grid, it works just fine. However, when I move that column to the sub-grid, I just see the list, without the kendo menu applied to it.
Two workarounds I tried:
http://dojo.telerik.com/OmiBu/3
Visuals:
Good and Bad
When right clicking on a cell view in a view based table view with an assigned menu the cell's row gets a blue outline and the context menu appears. How do I get the index of that row? The property clickedRow only works for cell based table views.
Note: my question is significantly different in that I need a solution for menu updates es explained previously:
I need the clicked row in the menuNeedsUpdate function when creating the new menu.
It appears that clickedRow indeed also works for view based table views, but it's not yet set in menuNeedsUpdate. So it cannot be used to adjust the items in the menu (e.g. show specific items only that apply to the clicked row). However, you can use the menu validation to enable/disable entries (there the clicked row value is set finally).
I have inspector view and because it contains a lot of UI I want to explore cocoa bindings to connect it to the model. The inspector view will update depending on the currently selected object in an outline view and the inspector view displays controls to alter properties (like colour, name, shape etc.) that can be changed.
This works well when only one row in the outline view is selected because the view has a one-to-one relationship with the model object. However, there are two special cases that I want to be able to catch:
Empty selection
If no items in the outline view are selected I want to display a special "No items selected view" placeholder view.
Multiple selection
If multiple items are selected I can either display a "Multiple items selected view" placeholder view or I can decide to let the changes apply globally to all selected model objects.
My question is how can these special cases be caught when using bindings? Moreover, how can I do behaviour "A" when there is an empty selection and behaviour "B" when there is a multiple section. This sort of thing is trivial when using target/action because you can just code the logic into the action method.
Bindings seem great when propagating changes to values but I'm unsure how to go about implementing bindings that require different decisions based on current selection state.