vscode extension how to display a form

爱⌒轻易说出口 提交于 2019-12-01 05:37:16

How much data do they need to enter? If it's not much, you should be able to handle it with a series of InputBoxes

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

showInputBox(options?: InputBoxOptions): Thenable<string>

Opens an input box to ask the user for input.

The returned value will be undefined if the input box was canceled (e.g. pressing ESC). Otherwise the returned value will be the string typed by the user or an empty string if the user did not type anything but dismissed the input box with OK.

Parameter   Description
options?: InputBoxOptions   
Configures the behavior of the input box.

Returns Description
Thenable<string>    
A promise that resolves to a string the user provided or to undefined in case of dismissal.

The Visual Studio Code API does not have any native methods to display forms to collect input. You can however, chain together Input Boxes, Quick Picks, etc... You can find all these methods under vscode.window.(...).

If these do not satisfy your needs you can implement a webview which allows you to render integrated HTML in Visual Studio Code and trade messages with the extension.

The most simple aproach would be to simple send all collected data from the form to the extension once you hit the submit button or something similar.

You have a nice little tutorial on how to do that here.

Another approach is to see how far you can go with editing JSON objects in settings.json. I thought I would need a form for 8-10 fields, but it turns out that I can create a settings template that has a series of labels and and entry fields (with type validation).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!