[英]In vscode how to add multiple options to the status bar
I am planning to add multiple options to the status bar.我打算向状态栏添加多个选项。 Is it possible?
是否可以?
Like, If we click on the language type of a file we see multiple options in the same way.就像,如果我们点击文件的语言类型,我们会以相同的方式看到多个选项。
how to create it?如何创建它?
Thanks谢谢
Use vscode.window.createStatusBarItem
to place an item on the status bar.使用
vscode.window.createStatusBarItem
在状态栏上放置一个项目。 When the item is clicked, it runs a command, that itself runs vscode.window.showQuickPick
to prompt the user to select from a list of items.单击该项目时,它会运行一个命令,该命令本身会运行
vscode.window.showQuickPick
以提示用户从项目列表中进行选择。
export function activate(context: vscode.ExtensionContext)
{
createStatusBarItem(context) ;
}
function createStatusBarItem(context: vscode.ExtensionContext)
{
// register a command that is invoked when the status bar
// item is clicked.
const myCommandId = 'myExtension.statusBarClick';
context.subscriptions.push(vscode.commands.registerCommand(myCommandId, async () =>
{
const pageType = await vscode.window.showQuickPick(
['shell', 'fetch rows, list in table'],
{ placeHolder: 'select type of web page to make' });
}));
// create a new status bar item that we can now manage
const item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
item.command = myCommandId;
context.subscriptions.push(item);
item.text = `my command`;
item.tooltip = `status bar item tooltip`;
item.show();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.