Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds additional functionality and flexibility to the menu API as well as fixing #110
Changes
addItem()
This method now allows for adding root level menu items as well as specifying the menu position, with the additional 'index' argument.
The index parameter is optional for both root level and submenus, excluding it will add the menu item to the end of the menu.
Additions
removeMenu(ID)
Added removeMenu shortcut which now allows:
instead of the more verbose
MenuItemProxy now uses this method to remove items as well.
enable() & disable()
Added enable() and disable() methods to MenuItemProxy which allows for enabling and disabling menu items via js
I debated removing the need to use .submenu() and instead return the submenu automatically when calling getItem() but decided to keep it in for now as it would remove the ability to change the title/accelerator keys and callbacks for the root level menu items unless additional methods were implemented to deal with those.
Ideally I'd like to make creating/editing menus much easier by passing a simply JS object with the desired menu configuration but doing so would require writing a ton of C code to parse the object and it just doesn't seem to be worthwhile to do for the time being. It can easily be done with the 10.9 JavascriptCore api so it may be something to look into for the MacGapNode project.