[TIMOB-13909] Android: MenuItem has no id in click event
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.1.0, Release 3.2.0 |
Fix Version/s | n/a |
Components | Android |
Labels | actionbar, android, identifier, menuitem |
Reporter | Mads Moller |
Assignee | Unknown |
Created | 2013-05-16T20:47:06.000+0000 |
Updated | 2018-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();
Tested and confirmed on Android 4.1.2 x86 emulator with Ti SDK 3.1 GA and 3.2 CI.
I just ran into this same issue myself. This is contrary to my expectations and is highly annoying.