1

In VSCode extensions, there are many different ways of adding buttons, specifically via the menus contribution points. While there is view/* stuff, there does not seem to be viewContainer.

Two questions:

  1. Am I misreading this, or is there no way to add a button to the viewContainer title?
    • Note: The built-in viewContainers have them, e.g.: enter image description here
  2. Even if that is not possible, is there maybe another way to somehow have a button appear, that is always visible, but within the viewContainer?
    • For example: buttons contributed to view/title only show up, if the mouse hovers over them or if the view is selected.
    • Note1: I am not asking for editor/title etc, but, specifically, buttons inside my custom viewContainer.
    • Note2: we sometimes use TreeView items as buttons, but aside from that.
    • Note3: I would largely prefer not having to manage a Webview in that viewContainer. I don't need one (despite a webview of course being able to deliver that functionality).
Domi
  • 22,151
  • 15
  • 92
  • 122
  • in the current VSC only the non-TreeView ViewContainers have these buttons like `Search` and `Run and Debug`, and the internal extension API has more options, how are these `Search` buttons defined in the code. – rioV8 Mar 28 '22 at 09:29
  • @Mark The visibility of these menu buttons is controlled by the `when` property, you specify for which view you want that button. Maybe if you set `"when": "true"` you will see the button always but then at different views. IN one of my extensions I have a `view/title` menu option but it only shows when the view has focus and thus the `when` property evaluates to true. – rioV8 Mar 28 '22 at 15:52
  • @rioV8 I am using the method shown here: https://code.visualstudio.com/api/extension-guides/tree-view#view-actions Using `"group": "navigation"` in the `view/title` and the icons for commands go into the `commands` section, and I am using no `when` clause. Have you seen this reference I cited - it is "fairly" good. I could add a gif to an answer I suppose. – Mark Mar 28 '22 at 16:15
  • Edited: @rioV8 I am not using any `when` clause in the `commands` section. And they always show (at least in debug mode which is the only place thus far I am using those buttons - but I don't think that makes a difference here.) The `vIewContainers` syntax is messy, note that in the package.json that `viewContainers` is a collection of two ojbects (activityBar and panel) which are themselves collections of viewcontainers; whereas `command` is just a collection of commands as it should be. – Mark Mar 28 '22 at 17:15
  • @Mark all menu items have `when` properties to specify the view where the button should go `"when": "view == nodeDependencies"`. with `group` you specify if it is in the title bar (visible when focus) or in the `...` menu of the title bar – rioV8 Mar 28 '22 at 18:51
  • @rioV8 Yes, I do have that `when` clause but it is just `"when": "view == editor-groups"`. The view doesn't need to be focused for that to be true - if it is the only view in the Side Bar visible at the time. – Mark Mar 28 '22 at 18:57

0 Answers0