Details

      Description

      Starting from API 11, menuItem methods must be run from the main thread, otherwise a Java exception will occur. MenuItemProxy needs to be refactor to address this issue.

      Testing code:

       
      var win1 = Ti.UI.createWindow({
          backgroundColor: 'blue',
          fullscreen: false
      });
      var tab1 = Ti.UI.createTab({
          window: win1,
          title: 'Tab 1'
      });
       
      var win2 = Ti.UI.createWindow({
          backgroundColor: 'yellow'
      });
      var tab2 = Ti.UI.createTab({
          window: win2,
          title: 'Tab 2'
      });
       
      var tabGroup = Ti.UI.createTabGroup({
      	activity: {
              onCreateOptionsMenu: function(e) {
                  var menu = e.menu;
                  var menuItem = menu.add({
                      title : "Item 1",
                      itemId: 1
                  });
                  var menuItem2 = menu.add({
                      title : "Item 2",
                      itemId: 2
                  });
                  menuItem.addEventListener("click", function(e) {
                      Ti.API.info("I was clicked");
                  });
              },
              
              onPrepareOptionsMenu: function(e) {
              	var menu = e.menu;
              	if (tab1.active) {
              		menu.findItem(1).setVisible(false);
              		var menuItem2 = menu.findItem(2);
              		menuItem2.setVisible(true);
              		Ti.API.info("item2 is checked: " + menuItem2.isChecked());
              		Ti.API.info("item2 is enabled: " + menuItem2.isEnabled());
              	
              	}
              	
              	if (tab2.active) {
              	    var menuItem = menu.findItem(1);
              		menuItem.setVisible(true);
              		Ti.API.info("item1 is checked: " + menuItem.isChecked());
              		Ti.API.info("item1 is enabled: " + menuItem.isEnabled());
              		menu.findItem(2).setVisible(false);
              	}
              }
          }
      });
        
      tabGroup.addTab(tab1);
      tabGroup.addTab(tab2);
      tabGroup.open();
      
      

      1. Run app.js
      2. Click on menu/optionMenu button: you should see Item 2 in tab1 and Item 1 in tab2. You should also see "is checked" and "is enabled" in logcat.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                hpham Hieu Pham
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-15332
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code