最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why Is My SubMenu In Context Menu Not Appearing Vscode Extension - Stack Overflow

programmeradmin0浏览0评论

I wanted to show a submenu with menus inside it in the right click context menu and i had this setup:

"categories": [
    "Other"
  ],
  "activationEvents": [
    "onCommand:colorquick.helloWorld"
  ],
  "main": "./dist/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "colorquick.helloWorld",
        "title": "Hello World"
      }
    ],
    "menus": {
      "editor/context": [
        {
          "submenu": "colorquick.submenu",
          "when": "editorTextFocus",
          "group": "navigation"
        }
      ],
      "editor/context/colorquick.submenu": [
        {
          "command": "colorquick.helloWorld",
          "group": "navigation"
        }
      ]
    },
    "submenus": [
      {
        "id": "colorquick.submenu",
        "label": "ColorQuick"
      }
    ]
  },

but it dosent come up, but if i dont use a submenu and i just put the command as a menu it comes up why is it not working;

I wanted to show a submenu with menus inside it in the right click context menu and i had this setup:

"categories": [
    "Other"
  ],
  "activationEvents": [
    "onCommand:colorquick.helloWorld"
  ],
  "main": "./dist/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "colorquick.helloWorld",
        "title": "Hello World"
      }
    ],
    "menus": {
      "editor/context": [
        {
          "submenu": "colorquick.submenu",
          "when": "editorTextFocus",
          "group": "navigation"
        }
      ],
      "editor/context/colorquick.submenu": [
        {
          "command": "colorquick.helloWorld",
          "group": "navigation"
        }
      ]
    },
    "submenus": [
      {
        "id": "colorquick.submenu",
        "label": "ColorQuick"
      }
    ]
  },

but it dosent come up, but if i dont use a submenu and i just put the command as a menu it comes up why is it not working;

Share Improve this question asked Feb 2 at 7:27 Ketsebaot GizachewKetsebaot Gizachew 251 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The issue is within the SubMenu definition.

While defining the "editor/context/colorquick.submenu" node, you don't need to prepend with editor/context/. The node must be your new SubMenu name instead.

So, your package.json should look something like this:

   "menus": {
      "editor/context": [
        {
          "submenu": "colorquick.submenu",
          "when": "editorTextFocus",
          "group": "navigation"
        }
      ],
      "colorquick.submenu": [
        {
          "command": "colorquick.helloWorld",
          "group": "navigation"
        }
      ]
    },
    "submenus": [
      {
        "id": "colorquick.submenu",
        "label": "ColorQuick"
      }
    ]
发布评论

评论列表(0)

  1. 暂无评论