Skip to content

Instantly share code, notes, and snippets.

@falkolab
Last active February 14, 2016 19:50
Show Gist options
  • Save falkolab/29ab007f4981f1d747f2 to your computer and use it in GitHub Desktop.
Save falkolab/29ab007f4981f1d747f2 to your computer and use it in GitHub Desktop.
Fix for not displayed ActionBar menu in Titanium SDK
// Not rendered menu fix
// Author: Andrey Tkachenko, falkolab
// Source: https://gist.github.com/falkolab/29ab007f4981f1d747f2
exports.fix = function(win) {
if (win.activity) {
win.addEventListener('open', function fixMenu(evt) {
evt.source.removeEventListener(evt.type, fixMenu);
var activity = evt.source.activity;
if (activity.onCreateOptionsMenu) {
activity.onCreateOptionsMenu = _.partial(function(func, e) {
func(e);
this._menuCreated = true;
}, activity.onCreateOptionsMenu);
_.delay(function(a) {
if(_.isUndefined(a._menuCreated)) {
Ti.API.warn('Menu not created! Creating now.');
a.invalidateOptionsMenu();
}
delete a._menuCreated;
a = null;
}, 500, activity);
}
});
}
};
// not rendered menu fix
// !!! do not place it to the `open` event handler.
OS_ANDROID && require('fixmenu').fix($.getView());
@iotashan
Copy link

WOOHOO!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment