scmJS docs

api.menu

MenuApi

Items in the editor's menu bar. A path whose last segment names no submenu makes one.

Members

add

add(path: MenuPath, item: MenuItemSpec): Disposable;

Add an item to the editor's menu bar.

api.menu.add("Tools", {
  label: "Count units…",
  icon: "plugin",
  enabled: () => api.document.isOpen(),
  run: () => api.ui.alert(`Player 1 has ${api.query.unitsOf(0).length} units.`),
});
Try it
// A path whose last segment names no submenu makes one, at the end of that menu.
api.menu.add("Tools/My plugin", { label: "About…", run: () => api.ui.alert(`${api.plugin.name} ${api.plugin.version ?? ""}`) });
// `after` puts an item directly under a built-in one, named by its English label.
api.menu.add("File", { label: "Open from My Site…", after: "Open Recent", run: () => api.ui.status("…") });
Try it

Types

Declarations only this group names.

TopMenutype

type TopMenu = "File" | "Edit" | "View" | "Layer" | "Scenario" | "Triggers" | "Tools" | "Plugins" | "Help";

Seen in

scmJS 0.7.3 + main@e2d8ba5 · Generated from the repository. The source is under the MIT license, which does not cover what ATTRIBUTION.md lists. StarCraft and Brood War are trademarks of Blizzard Entertainment; this project ships none of their data.