Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

05. 自定义菜单 Menu-例子 #5

Open
PDKSophia opened this issue Feb 4, 2021 · 0 comments
Open

05. 自定义菜单 Menu-例子 #5

PDKSophia opened this issue Feb 4, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation vscode

Comments

@PDKSophia
Copy link
Owner

PDKSophia commented Feb 4, 2021

场景

适用于一些快捷按钮的自定义,可通过Menu操作

代码展示

// demo5 自定义菜单
import * as vscode from 'vscode'
module.exports = function (context: vscode.ExtensionContext) {
  let disposable = vscode.commands.registerCommand('beehive.customMenu', () => {
    vscode.window.showInformationMessage("I' am custom menu !")
  })
  context.subscriptions.push(disposable)
}
// extension.ts
import * as vscode from 'vscode'
export function activate(context: vscode.ExtensionContext) {
  console.log('your extension "sugar-demo-vscode" is now active!')
  require('./beehive-customMenu')(context) // demo5 自定义菜单
}
export function deactivate() {}
// package.json
  "commands": [
      {
        "command": "beehive.customMenu",
        "title": "demo5: 启动自定义菜单"
      }
    ],
    "menus": {
      "editor/title": [
        {
          "command": "beehive.customMenu",
          "alt": "beehive.customMenu",
          "group": "navigation"
        }
      ]
    },

效果展示

点击之后,触发事件

源码展示

@PDKSophia PDKSophia added documentation Improvements or additions to documentation vscode labels Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation vscode
Projects
None yet
Development

No branches or pull requests

1 participant