Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13909] Android: MenuItem has no id in click event

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.0, Release 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelsactionbar, android, identifier, menuitem
ReporterMads Moller
AssigneeUnknown
Created2013-05-16T20:47:06.000+0000
Updated2018-02-28T20:03:55.000+0000

Description

*Problem* MenuItem has only title as a identifier on the click event. This is a very bad idea, when you are building multi language apps. With any other Ti Proxy object, I get the id and all the custom properties in the e.source object. *Steps to reproduce* 1. Run test case on Android 2. Open the menu - on the emulator this can be done with the circular "Menu" button 3. Click the item, observe that e.source.customProp returns "undefined" *Test case*
var win = Ti.UI.createWindow({
	fullscreen : true
});

var activity = win.activity;

activity.onCreateOptionsMenu = function(e) {
	var menu = e.menu;
	var menuItem = menu.add({
		title : "Item 1",
		icon : "KS_nav_ui.png",
		showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM,
		customProp: "test"
	});
	menuItem.addEventListener("click", function(e) {
		Ti.API.info("e.source.title: " + e.source.title);
		Ti.API.info("e.source.customProp: " + e.source.customProp); // Does not work
	});
};

win.open();

Comments

  1. Daniel Sefton 2013-05-17

    Tested and confirmed on Android 4.1.2 x86 emulator with Ti SDK 3.1 GA and 3.2 CI.
  2. Vance Lucas 2013-09-30

    I just ran into this same issue myself. This is contrary to my expectations and is highly annoying.

JSON Source