[英]How to get the current selected view everytime when view is changed from vscode API
我認為您正在尋找onDidChangeActiveTextEditor
const vscode = require('vscode');
function runFunction() {
// Your code here
}
vscode.window.onDidChangeActiveTextEditor(event => {
if (event.document.uri.scheme === 'your-view-scheme') {
runFunction();
}
});
如果您的視圖是TreeView
,您可以聽取它的可見性:
const treeViewVisibilityListener = this.tabView.onDidChangeVisibility(async event => {
console.log("here");
});
context.subscriptions.push(treeViewVisibilityListener);
event
將具有值{visible: true}
或{visible: false}
取決於它是否被打開。 它也適用於視圖從活動欄或面板或輔助欄隱藏或取消隱藏的情況 - 取決於用戶移動它的位置。
如果您的視圖是Webview
,您可以使用相同的.onDidChangeVisibility
偵聽器。
如果點擊/顯示的視圖不是您的,則這些不會觸發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.