Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-application-menu-template

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-application-menu-template

Electron Application Menu Template

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Electron Application Menu Template

Why?

As far as I can tell, you cannot delete a menu item from existing application menu (You can add new ones though). You cannot change the click handling function either (You can change it, but it won't take effect).

So what could you do if you would like to delete an menu item or overwrite the click handling function? You need to build a new application menu from scratch. This project provide you with a template so that you can build an application menu quickly.

The template returned should generate application menu identical (almost) to the default one provided by an Electron app.

Install

yarn add electron-application-menu-template

Usage

import {newTemplate} from 'electron-application-menu-template';

const template = newTemplate();

// Optional: make some modifications to the template
const fileMenu = template.find(item => item.label === 'File')!;
(fileMenu.submenu! as MenuItemConstructorOptions[]).unshift(
  {
    label: 'Open',
    accelerator: 'CmdOrCtrl+O',
    async click() {
      // open a file here
    },
  },
  {
    type: 'separator',
  }
);

app.whenReady().then(() => {
  Menu.setApplicationMenu(Menu.buildFromTemplate(template));
});

FAQs

Package last updated on 05 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc