Details: Could not find symbol 'onSelect'.___menu in WatchFace___.

Hello, I need help with this menu.

This works for me by default and correctly:

addItem(new Item(:Apnoe, "Apnoe", Rez.Strings.Apnoe, null, Application.Properties.getValue("Apnoe")));

When i try to add this line to the menu i get an error in the simulator:

Details: Could not find symbol 'onSelect'.


Buzz = new Ui.MenuItem(Rez.Strings.Buzz, null, :Buzz, null);
self.addItem(Buzz);

Here I connect the onSelect function:

class SettingsMenuInputDelegate extends WatchUi.Menu2InputDelegate{

var mode;

function initialize(mode) {

self.mode = mode;
Menu2InputDelegate.initialize();
}

function onSelect(item){
item.onSelect(mode);

 }
}

I'm asking for help, what should I modify so that the menu I'm adding works for me?

Thank you

  • MenuItem doesn't have onSelect

  • Thank you, and what should the additional code look like so that the "self" value works for me?

    Buzz = new Ui.MenuItem(Rez.Strings.Buzz, null, :Buzz, null);
    self.addItem(Buzz);

  • Look at the Menu2Sample in the SDK,

  • In which line is the error?

  • They need to do exactly this, but to make it work incl. values ​​of self.

    var Buzz = new WatchUi.Menu2({:title=>Rez.Strings.Buzz});
    Buzz.addItem(new WatchUi.MenuItem(Rez.Strings.Buzz, null, :Buzz, null));
    self.addItem(Buzz);

    Now it shows me the error:

    Error: Unhandled Exception
    Exception: UnexpectedTypeException: Unexpected type, expected WatchUi.MenuItem
    stack:
    - addItem() at 704b03c0.mb:2576 0x30002c08

  • I use self for the TimePicker parameter, basically it is two values, that means:

    function refreshSubLabels() {

    Apnoe.setSubLabel(Prefs.getCount().toString());
    Buzz.setSubLabel(Prefs.getExerciseDuration().toString());

    }

    it is so that the entered - changed values ​​are immediately updated in the menu.

    I am sending a picture for a better one
    an idea.

  • TimePicker isn't system class but i think there is no addItem function in

  • I'm not calling via self, only the module

    Pref.

    I would only need help from you - to make a change,


    addItem(new Item(:Apnoea, "Apnoea", Rez.Strings.Apnoea, null, Application.Properties.getValue("Apnoea")));

    on

    Buzz = new Ui.MenuItem(Res.Strings.Buzz, null, :Buzz, null);
    self.addItem(Buzz);

    I know that the onSelect method is not used by MenuItem, but maybe it can be modified somehow so that I can have this item in the menu with the selection "self".?

    Thank you

  • It's impossible to help without all code Disappointed

    But if you use self.foo() it means that class self (or rather object of class so it has to be created early with new) has to have function foo.

    Apnoe and Buzz has to be MenuItem so add them to Menu2 and in Menu2InputDelegate

    function onSelect(item)
          {
            if(item.getId() == ID_BUZZ________)
            {
                     //do something, with buzz
            } else if(item.getId() == ID_APNOE________)
            {
                    //show time picker view
            }
          }