Menu2 , onSelect ( item ) save .

Hi, I have a question.
Is it possible to use two storage types in Menu 2 == on Select(item)?
I think
Storage.setValue
Application.Properties.setValue.

The point is that I want to save something to the watch storage and have the transformations in Application.Properties.setValue.

Here is the shortcode:

public function onSelect(item) as Void {


        if (item instanceof WatchUi.IconMenuItem) {
            item.setSubLabel((item.getIcon() as colors).nextState(item.getId()));
        } else if (item instanceof WatchUi.ToggleMenuItem) {
            Storage.setValue(item.getId() as Number, item.isEnabled());
            Properties.setValue(item.getId() as Number, item.isEnabled()); 
        }

Thanks for the reply.

  • What doesn't work for you?  Do you get an error?  What you posted should work, assuming the keys you use are defined for the property you are using in that setValue().

    As a rule, I don't put anything in Application.Properties unless it's something the user can change with apps settings, and if it's in Application.Properrties, you shouldn't need it in Application.Storage, as you already have access to it.

  • The code i posted works for me. just wondering if anyone else is also using the same solution or a different one?

    I understand that everything should be stored in Storage, but I don't know if it is reasonable to store the time format change and others in the watch storage, that means

    var military = Properties.getValue("UseMilitaryFormat") as Boolean;
    Menu2.addItem(new WatchUi.ToggleMenuItem(Rez.Strings.MF, Rez.Strings.SMF, "UseMilitaryFormat", military, null));

    or should I do this:
    var military = Storage.getValue("UseMilitaryFormat") as Boolean;?

  • Properties. This is a user setting, isn't it?

  • So I left it unchanged and as jim_m_58 wrote that it stores everything in storage, I will do the same based on the fact that it is the same in the MENU2 preview.

    Thank you very much for the information, here I send an example of how I solve it:

    iconMenu.addItem(new WatchUi.ToggleMenuItem("UseMilitaryFormat", {:enabled=>"ON", :disabled=>"OFF"}, 3, Storage.getValue(3), {:alignment=>WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT}));
  • You can see how I toggle things in Menu2 in the example I posted in this thread. Also how I use the standard setting on the watch for 12/24 hour time

    https://forums.garmin.com/developer/connect-iq/f/discussion/349473/simple-example-wf-that-shows-a-bunch-of-things

  • The advantage of storing in properties is that you can make the settings work from Connect IQ (and Garmin Express) as well. I like that, it's sometimes more accessible than clicking with the watch buttons.

  • In 9 years of doing watch faces, I can't recall a single user concerned that I used the standard watch settings for 12/24 hour mode.  For one thing, you don't change them that often, and on the app side, you save a bit of memory if you use the standard setting

  • Maybe, but I don't think he was asking specifically about the military time format (which IMHO isn't 100% the same as the 24h setting) but rather in general how to store state from the menu's.

  • From on-device settings and not app settings....

    And I told him he didn't need to save the same thing to both Properties and Storage, and pointed him to two example of watch faces with on device settings, one of which also shows how to use the standard setting for 12/24 hour mode.

  • Yes, my question was general, I only gave an example with military time.
    I personally like the Menu in the watch and I only make the settings preferences once, so I don't have to change them every time. GCM is a user maybe better way, but 1000 people equals 1000 tastes.Sunglasses