Skip to content

Instantly share code, notes, and snippets.

@falkolab
Last active Feb 14, 2016
Embed
What would you like to do?
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

iotashan commented Dec 10, 2015

WOOHOO!

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