Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the 'OK' button from QuickPick

I'm developing a VS-Code extension using Typescript.

In one of the flows, it creates a QuickPick menu using the following API:

let quickPick: vscode.QuickPick<vscode.QuickPickItem> = vscode.window.createQuickPick();
quickPick.items = this.getValues();
quickPick.canSelectMany = true; // Enable checkboxes

// Set listeners
quickPick.onDidChangeSelection(items => {
    // --> Do an important action here <--
});
quickPick.show();

When the user clicks on one of the checkboxes, the action occurs immediately -> There is no need for OK button in my scenario. Quick pick items

Does somebody know how to remove the OK button?

Thanks.

like image 793
yahavi Avatar asked Apr 07 '26 14:04

yahavi


2 Answers

It would seem that calling quickPick.ok(false) to hide the button would work.

But looking at the code the ok button is always rendered for canSelectMany QuickPicks.

You could use quickPick.customButton(true) together with quickPick.customLabel("your label") to replace the ok button instead.

However when I look at your scenario maybe you do not need multi select if each click on a checkmark already performs the action. Checkmarks are usually used only to mark multiple things to happen, hence the OK button to run the combined actions.

like image 192
philk Avatar answered Apr 09 '26 07:04

philk


just add quickPick.ok(false) to hide your ok button.

You can also customize you ok button with quickPick.customButton(true) with quickPick.customLabel("label") to replace ok and ad it with ur custom ok button

like image 39
PixelGM Avatar answered Apr 09 '26 05:04

PixelGM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!