Skip to content

Commit 7af3a3f

Browse files
committed
handle 'back' as a separate menu option
1 parent ce42ab4 commit 7af3a3f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/graphical_menu.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
exports.list = function(g, items) {
44
var options = items[""];
55
var menuItems = Object.keys(items);
6-
if (options) menuItems.splice(menuItems.indexOf(""),1);
6+
if (options) {
7+
menuItems.splice(menuItems.indexOf(""),1);
8+
if (options.back) { // handle 'options.back'
9+
items["< Back"] = options.back;
10+
menuItems.unshift("< Back");
11+
}
12+
}
713
if (!(options instanceof Object)) options = {};
814
if (options.selected === undefined)
915
options.selected = 0;

modules/graphical_menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Each object is as follows:
8080
var menuinfo = {
8181
"" : {
8282
"title": "...", // optional, the menu's title
83+
"back" : function() { } // optional - adds a menu item to go 'back' which calls this function
8384
"selected": 0, // optional, first selected menu item's index
8485
"fontHeight": 0, // optional, height of the font being used (default is 6)
8586
"y": 0, // optional, y offset of menu

0 commit comments

Comments
 (0)