Menu items can now be arrays of objects

* Allows custom members of each item
* 'data' overrides selection (vs returning the index)
* 'text' is the default member for text if no formatters are supplied
* formatters: 'itemFormat' and 'focusItemFormat', e.g. "{member1} - {member2}"
This commit is contained in:
Bryan Ashby 2018-01-27 22:21:48 -07:00
parent 974ee1b389
commit 7a2df56855
4 changed files with 77 additions and 31 deletions

View file

@ -113,9 +113,9 @@ ToggleMenuView.prototype.getData = function() {
};
ToggleMenuView.prototype.setItems = function(items) {
items = items.slice(0, 2); // switch/toggle only works with two elements
ToggleMenuView.super_.prototype.setItems.call(this, items);
this.items = this.items.splice(0, 2); // switch/toggle only works with two elements
this.dimens.width = this.items.join(' / ').length; // :TODO: allow configurable seperator... string & color, e.g. styleColor1 (same as fillChar color)
this.dimens.width = items.join(' / ').length; // :TODO: allow configurable seperator... string & color, e.g. styleColor1 (same as fillChar color)
};