In breef:
I have created a menu object in a function, but I cannot access that menu object in the main script.
The full explanation:
In the function createMyMenu() I do create a menu object with some items and the menu is shown. This works fine and the user can move up/down in the menu by using the buttons on the Pebble smartwatch.
Problem is that the user cannot select any items, just navigate in the menu.
If I create the menu object in the main script, I (of course) works just fine, but if I create the menu object in a function, the user can not select any menu item.
Question: How can I create a menu in a function and then use that menu object in the main script the same way as if the menu was created in the main script?
The code:
function createMyMenu()
{
// Some code to create the menu object myMenu. Works fine.
myMenu.show(); // Also works fine, the menu and it contents are displayed.
return myMenu; // No errors
}
And the script
mainMenu = createMyMenu(); // Create the menu.
mainMenu.on('select', function(e) // This does not seem to be executed.
{
// Code to execute when the user selects a menu item.
}