Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15126] Android: Menus do not respond in regards to menu button being pressed

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-12T23:41:42.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.1.3, Release 3.2.0
ComponentsAndroid
Labelsandroid, defect, menu, module_android, qe-testadded, regression, titanbeta, triage
ReporterShawn Lipscomb
AssigneeHieu Pham
Created2013-09-12T14:18:28.000+0000
Updated2014-04-22T06:35:21.000+0000

Description

Problem

Under mobile SDK 3.1.2.GA, normal menus don't pop up any more when the menu button is pressed. Works fine in 3.1.1.GA. Therefore, this is a regression.

Testcase

Using the following code, run the app and press the menu button. With SDK 3.1.2.GA, no menu will appear. With SDK 3.1.1.GA, the menu will appear as normal. {panel:title=app.js}
var win1=Ti.UI.createWindow({ layout:'vertical', 
                              navBarHidden:true, 
                              exitOnClose:true,
                              url:'win1.js' });
win1.open();
{panel} {panel:title=win1.js}
var win1=Ti.UI.currentWindow;
var Label1=Ti.UI.createLabel({ text:'Push the menu button' });
win1.add(Label1);

function MenuHandler(evt)
{
  switch (evt.source.order)
  {
    case 0 : alert('First Option');
             break;
    case 1 : alert('Second Option');
             break;
  }
}

function CreateMenu(evt)
{
  var MenuItem1,MenuItem2;
  MenuItem1=evt.menu.add({title:'Option 1', icon:null, order:0, itemId:0});
  MenuItem2=evt.menu.add({title:'Option 2', icon:null, order:1, itemId:1});
  MenuItem1.addEventListener('click',MenuHandler);
  MenuItem2.addEventListener('click',MenuHandler);
}

win1.activity.onCreateOptionsMenu=CreateMenu;
{panel}

Comments

  1. Federico Casali 2013-09-12

    Investigating. Issue seems to be related to using an Android MenuItem in a Window using the 'url' property, thus being opened in a sub-context. The following code is the one provided in the description, but without using the 'url' property and defining everything in a single context. This is working as expected using also 3.1.2.GA and latest 3.1.3
       var win1 = Ti.UI.createWindow({
       	layout : 'vertical',
       	navBarHidden : true,
       	exitOnClose : true,
       	// url : 'win1.js'  //commenting out - using url opens a window in a sub-context
       });
       
       win1.open();
       // commenting out the next line - currentWindow valid only when using a sub-context
       // var win1 = Ti.UI.currentWindow;
       
       var Label1 = Ti.UI.createLabel({
       	text : 'Push the menu button'
       });
       win1.add(Label1);
       
       function MenuHandler(evt) {
       	switch (evt.source.order) {
       		case 0 :
       			alert('First Option');
       			break;
       		case 1 :
       			alert('Second Option');
       			break;
       	}
       }
       
       function CreateMenu(evt) {
       	var MenuItem1, MenuItem2;
       	MenuItem1 = evt.menu.add({
       		title : 'Option 1',
       		icon : null,
       		order : 0,
       		itemId : 0
       	});
       	MenuItem2 = evt.menu.add({
       		title : 'Option 2',
       		icon : null,
       		order : 1,
       		itemId : 1
       	});
       	MenuItem1.addEventListener('click', MenuHandler);
       	MenuItem2.addEventListener('click', MenuHandler);
       }
       
       win1.activity.onCreateOptionsMenu = CreateMenu; 
       
  2. Shawn Lipscomb 2013-09-12

    Federico, yes, I noticed that a simple "all-app.js" example worked. But this bug report is about it no longer working in url-based (secondary context) windows.
  3. Hieu Pham 2013-09-12

    master PR: https://github.com/appcelerator/titanium_mobile/pull/4683
  4. Hieu Pham 2013-09-12

    3.1.X PR: https://github.com/appcelerator/titanium_mobile/pull/4684
  5. Federico Casali 2013-09-13

    Verified as fixed TiSDK 3.1.3.v20130912171547 TiStudio 3.1.3.201309132456 CLI 3.1.2 GA Closing

JSON Source