Skip to content

Commit

Permalink
hello world menu
Browse files Browse the repository at this point in the history
  • Loading branch information
abose authored Mar 13, 2023
1 parent 1167934 commit 655a7bc
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,41 @@
// See detailed docs in https://github.com/phcode-dev/phoenix/wiki/How-To-Write-Extensions-And-Themes
// A good place to look for code examples for extensions: https://github.com/phcode-dev/phoenix/tree/main/src/extensions/default

// A simple extension that adds an entry in "file menu> hello world"
define(function (require, exports, module) {
"use strict";

// Brackets modules
var AppInit = brackets.getModule("utils/AppInit"),
DefaultDialogs = brackets.getModule("widgets/DefaultDialogs"),
Dialogs = brackets.getModule("widgets/Dialogs");
const AppInit = brackets.getModule("utils/AppInit"),
DefaultDialogs = brackets.getModule("widgets/DefaultDialogs"),
Dialogs = brackets.getModule("widgets/Dialogs"),
CommandManager = brackets.getModule("command/CommandManager"),
Menus = brackets.getModule("command/Menus");

// Initialize extension once shell is finished initializing.
AppInit.appReady(function () {
console.log("hello world");
// Function to run when the menu item is clicked
function handleHelloWorld() {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_INFO,
"hello", "world"
"hello",
"world"
);
});
}

});
// 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);

// 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);
menu.addMenuItem(MY_COMMAND_ID);

// We could also add a key binding at the same time:
//menu.addMenuItem(MY_COMMAND_ID, "Ctrl-Alt-W");
// (Note: "Ctrl" is automatically mapped to "Cmd" on Mac)

// Initialize extension once shell is finished initializing.
AppInit.appReady(function () {
console.log("hello world");
});
});

0 comments on commit 655a7bc

Please sign in to comment.