Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a custom dialog in VSCode?

I'm developing an extension for VSCode, and I want to display a custom dialog to help the user configure an ini file.

Is it possible to create a custom dialog with labels and inputs?

like image 925
thur Avatar asked Sep 14 '16 01:09

thur


People also ask

How do I create a VS Code template?

In VSCode, open a folder that will contain your new project. Use the Command Palette to execute the command "Project: Create Project From Template". A list of available templates should appear. Select the desired template.

How do you add a command palette in VS Code?

Command Palette# VS Code is equally accessible from the keyboard. The most important key combination to know is Ctrl+Shift+P, which brings up the Command Palette. From here, you have access to all of the functionality of VS Code, including keyboard shortcuts for the most common operations.


1 Answers

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).

like image 166
Llewey Avatar answered Sep 28 '22 23:09

Llewey