简体   繁体   English

从VSCode扩展访问窗口对象

[英]Access window object from VSCode Extension

I need to know if the instance where the extension is running is focused or not. 我需要知道扩展正在运行的实例是否集中。 For that I want to use the window.document.isFocused() method. 为此,我想使用window.document.isFocused()方法。

Is there any way to access the window object from the extension? 有什么办法可以从扩展名访问窗口对象? If not, is there any method in the vscode api that can achieve the same functionality? 如果没有,vscode api中是否有任何方法可以实现相同的功能?

Thanks 谢谢

No, extensions cannot access VS Code's DOM. 不可以,扩展不能访问VS Code的DOM。

VSCode loads at most once instance of an extension per window. VSCode每个窗口最多加载一次扩展实例。 To determine if an editor within the window is active or not, try the window.activeTextEditor property and the window.onDidChangeActiveTextEditor event: https://code.visualstudio.com/docs/extensionAPI/vscode-api#_window 要确定窗口内的编辑器是否处于活动状态,请尝试使用window.activeTextEditor属性和window.onDidChangeActiveTextEditor事件: https : //code.visualstudio.com/docs/extensionAPI/vscode-api#_window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM