7

API docs によると、メッセージ ボックスは 2 番目の引数を取ることができます: メッセージ ボックスのアクションとして機能する文字列の配列 (通常、閉じるボタン/アクションは 1 つだけです):

https://code.visualstudio.com/docs/extensionAPI/vscode-api#_window

showInformationMessage(message: string, ...items: string[]): Thenable<string>

だから私はこれを試しました:

vscode.window.showInformationMessage('hello world', ['test','taco','cheeseburger'], function(value){
  console.log(value + " was clicked");
});

しかし、これはうまくいかないようです。通常どおり、メッセージ ボックスと [閉じる] ボタンが表示されます。しかし、閉じるボタンの左側には、テキストやタイトルのない別の単一のボタンが表示されます。

別の関数定義は次のとおりです。

showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T>

だから私はこのようなことを試しました:

let message: vscode.MessageItem = { title: 'testing' };
vscode.window.showInformationMessage('hello', [message], function(value){
  console.log(value + " was clicked");
});

しかし、それもうまくいかないようです。これに関するドキュメントはほとんどないので、私はそれを理解することができません。

4

1 に答える 1

18
vscode.window
  .showInformationMessage('hello', 'test', 'taco', 'cheeseburger')
  .then(selection => {
    console.log(selection);
  });

また

vscode.window
  .showInformationMessage('hello', ...['test', 'taco', 'cheeseburger'])
  .then(selection => {
    console.log(selection);
  });

両方とも、次のようなダイアログが表示されます。

于 2016-11-17T11:05:21.253 に答える