How to create a custom dialog in vscode?

2019-03-25 11:17发布

问题:

I'm developing an extension for vscode, and I want to display a custom dialog to help the user configure an ini file.
It's possible to create a custom dialog, with labels and inputs?

回答1:

You cannot create new UI elements, but if you want to get inputs from the user you can use code like below:

let options: InputBoxOptions = {
    prompt: "Label: ",
    placeHolder: "(placeholder)"
}

window.showInputBox(options).then(value => {
    if (!value) return;
    answer1 = value;
    // show the next dialog, etc.
});

This will use the same UI as the command palette (when you press Ctrl+P, or any of the other commands that open the input box at the top).