Skip to content

Commit

Permalink
Merge pull request pebble#133 from redtoad/patch-1
Browse files Browse the repository at this point in the history
Fix ReferenceError when using callback.
  • Loading branch information
Meiguro committed Mar 12, 2016
2 parents 7b3aad5 + 45522bc commit 8593f65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/js/ui/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,19 @@ Menu.prototype.item = function(sectionIndex, itemIndex, item) {
return this;
};

Menu.prototype.selection = function(callback_or_sectionIndex, itemIndex) {
if (typeof callback_or_sectionIndex === 'function') {
Menu.prototype.selection = function(sectionIndex, itemIndex) {
var callback;
if (typeof sectionIndex === 'function') {
callback = sectionIndex;
sectionIndex = undefined;
}
if (callback) {
this._selections.push(callback);
simply.impl.menuSelection();
} else {
this._selection = {
sectionIndex: callback_or_sectionIndex,
itemIndex: itemIndex
sectionIndex: sectionIndex,
itemIndex: itemIndex,
};
this._select();
}
Expand Down
3 changes: 3 additions & 0 deletions src/simply/simply_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ static void simply_menu_add_item(SimplyMenu *self, SimplyMenuItem *item) {
}

static MenuIndex simply_menu_get_selection(SimplyMenu *self) {
if (!self->menu_layer.menu_layer) {
return (MenuIndex) {};
}
return menu_layer_get_selected_index(self->menu_layer.menu_layer);
}

Expand Down

0 comments on commit 8593f65

Please sign in to comment.