Created
June 15, 2014 19:52
-
-
Save tadija/5fa3096c4256bbbea0eb to your computer and use it in GitHub Desktop.
SKETCH: explore menu actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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