Skip to content

Instantly share code, notes, and snippets.

@tadija
Created June 15, 2014 19:52
Show Gist options
  • Save tadija/5fa3096c4256bbbea0eb to your computer and use it in GitHub Desktop.
Save tadija/5fa3096c4256bbbea0eb to your computer and use it in GitHub Desktop.
SKETCH: explore menu actions
function logMenu(menu) {
var count = [menu numberOfItems];
for (var n = 0; n < count; ++n) {
var item = [menu itemAtIndex:n];
if (![item isSeparatorItem]) {
log([item class]);
if ([item hasSubmenu]) {
logMenu([item submenu]);
} else {
var action = NSStringFromSelector([item action]);
if (action) {
print([item title] + " -> " + action);
}
}
}
}
}
try {
var menu = [[NSApplication sharedApplication] mainMenu];
logMenu(menu);
} catch (e) {
log(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment