Created
July 11, 2012 00:27
-
-
Save tpryan/3087135 to your computer and use it in GitHub Desktop.
Sample of Menu removing for Brackets.
This file contains 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
define(function (require, exports, module) { | |
'use strict'; | |
var CommandManager = brackets.getModule("command/CommandManager"), | |
Menus = brackets.getModule("command/Menus"); | |
// Function to run when the menu item is clicked | |
function handleHelloWorld() { | |
menu.removeMenuItem(MY_COMMAND_ID); | |
window.alert("Hello, world!"); | |
} | |
// Function to run when the menu item is clicked | |
function handleHelloWorldContext() { | |
contextMenu.removeMenuItem(MY_COMMAND_ID_CONTEXT); | |
window.alert("Hello, world Context!"); | |
} | |
// First, register a command - a UI-less object associating an id to a handler | |
var MY_COMMAND_ID = "helloworld.sayhello"; // package-style naming to avoid collisions | |
CommandManager.register("Hello World", MY_COMMAND_ID, handleHelloWorld); | |
var MY_COMMAND_ID_CONTEXT = "helloworld.context.sayhello"; // package-style naming to avoid collisions | |
CommandManager.register("Hello World Context", MY_COMMAND_ID_CONTEXT, handleHelloWorldContext); | |
// Then create a menu item bound to the command | |
// The label of the menu item is the name we gave the command (see above) | |
var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU); | |
var contextMenu = Menus.getContextMenu("project-context-menu"); | |
contextMenu.addMenuItem(MY_COMMAND_ID_CONTEXT); | |
menu.addMenuItem(MY_COMMAND_ID); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment