我该如何控制”选择树视图项目?

发布于 2025-01-23 00:56:23 字数 401 浏览 3 评论 0原文

如果您在VS代码扩展中有树视图,则单击其中的项目时,它们会被选中(在我的颜色主题中突出显示了绿色)。单击它们,它们的光线很大。请参阅下面的屏幕截图,在“文件资源管理器”视图中:

”“在此处输入图像说明”

我想“控制”此行为。我想禁用当用户单击这些项目时默认情况下发生的突出显示,禁用当它们单击时发生的未点亮点,并在突出显示项目时控制我的扩展代码。我想在我的扩展名自定义树视图中做到这一点,而不是现有的树景。

If you have a TreeView in a VS Code extension, when you click on the items in it, they get selected (highlighted green, in my color theme). Click away from them and they get un-highlighted. See the below screenshot, in the file explorer view:

enter image description here

I'd like to "take control" of this behavior. I want to disable the highlighting that happens by default when the user clicks on these items, disable the un-highlighting that happens when they click away, and control in my extension code when the items get highlighted. I'd like to do this in my extension's custom TreeView, not an existing one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白昼 2025-01-30 00:56:23

使用树视图项目的“显示”方法。您可以指定是否被“选择”并“集中”。

基本上,您可以通过强制整个树景的刷新来更改所需的结构。您可能已经知道,如果您开始为VSCODE制作TreeView扩展...

但是,当它完成重新渲染树时,您将“揭示”一个节点,并使用“选择”参数选项,以将该节点作为node在树上进行选择。 ...要选择另一个节点,只是“揭示”另一个节点。 (如果仅选择另一个节点而不更改树的结构,则无需强制对树视图的完整刷新

。 .com/api/core/vscode-api#treeview%3ct%3E“ rel =” nofollow noreferrer“> treeview api

另请参阅 leotheg 在VSCODE上的扩展名,用于控制哪个节点的实际代码示例

Use the 'reveal' method of the treeview item. You can specify if it's to be 'selected' and also 'focused'.

Basically, you can change to the structure you want by forcing a refresh of the whole treeview. You probably already know that if you started making treeview extensions for vscode...

But then, right as it finishes re-rendering the tree, you 'reveal' a node, with the 'select' parameter option, to have that node as the selection in the tree. ...To have another node selected, just 'reveal' another one. (no need to force a full refresh of the treeview if it's only to have another node selected without changing the structure of the tree.)

see the 'reveal' method of the treeview here treeview API

Also see the leointeg extension on vscode for actual code example of controlling which node is selected

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文