vscode-elements / elements

Web component library for developing Visual Studio Code extensions
https://vscode-elements.github.io
MIT License
156 stars 28 forks source link

How to create a context menue on a TreeItem? #205

Open DavidBal opened 1 month ago

DavidBal commented 1 month ago

Hi,

i would like to generate a custome context menue on Item of Tree.

image

Is there a way to archive this?

Thanks in advance!

Kind regards, David

neko-para commented 1 month ago

Generally, the context item itself is kind of seperate window, then the major problem seems to be the way to listen to the right click of the items. However, #152 should definitely solve this problem, thus waiting for it would be a better choice, rather than request a feature for the deprecated tree widget 🤔

bendera commented 1 month ago

Hi,

i would like to generate a custome context menue on Item of Tree.

Is this what you are looking for? https://code.visualstudio.com/api/extension-guides/webview#context-menus

DavidBal commented 1 month ago

Hi, i would like to generate a custome context menue on Item of Tree.

Is this what you are looking for? https://code.visualstudio.com/api/extension-guides/webview#context-menus

Yes, but i see no way to place the "data-vscode-context" on the element via the provided api.

Generally, the context item itself is kind of seperate window, then the major problem seems to be the way to listen to the right click of the items. However, #152 should definitely solve this problem, thus waiting for it would be a better choice, rather than request a feature for the deprecated tree widget 🤔

That looks intressting, i can wait.


Thanks.

bendera commented 1 month ago

I'm not sure if it works but you can try something like this:

document.querySelector('vscode-tree').shadowRoot.querySelector('ul:nth-child(2) li').dataset.vscodeContext = '{"webviewSection": "editor", "preventDefaultContextMenuItems": true}'