Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickPickItem button API support #130519

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Aug 10, 2021

Example:

image

const quickpick = window.createQuickPick();
const item = {
	label: 'Accounts',
	// NEW
	buttons: [{
		iconPath: new ThemeIcon('accounts-view-bar-icon'),
		tooltip: 'Eyyy'
	},
	{
		iconPath: new ThemeIcon('gear'),
		tooltip: 'zxcv'
	},
	{
		iconPath: new ThemeIcon('callhierarchy-incoming')
	},
		QuickInputButtons.Back
	]
};
quickpick.items = [
	item,
	{
		label: 'HELLO',
		// NEW
		buttons: [{
			iconPath: new ThemeIcon('callstack-view-session'),
		},
		{
			iconPath: new ThemeIcon('debug-breakpoint'),
			tooltip: 'Eyyy'
		},
		{
			iconPath: new ThemeIcon('debug-breakpoint'),
			tooltip: 'zxcv'
		}]
	}];

// NEW
quickpick.onDidTriggerItemButton((e) => {
	window.showInformationMessage((e.item === item) + '');
	window.showInformationMessage((e.button === QuickInputButtons.Back) + '');
});

// The top buttons. Not new.
quickpick.buttons = [
	{
		iconPath: new ThemeIcon('accounts-view-bar-icon'),
		tooltip: 'Eyyy'
	},
	{
		iconPath: new ThemeIcon('gear'),
		tooltip: 'zxcv'
	},
	{
		iconPath: new ThemeIcon('callhierarchy-incoming')
	},
	QuickInputButtons.Back
];
quickpick.onDidTriggerButton((e) => {
	window.showInformationMessage('top button: ' + e.tooltip);
});
quickpick.show();

This PR fixes #88716

Is this testable? I feel like integration tests can't test this because it requires someone to click on a button.

@TylerLeonhardt TylerLeonhardt added this to the August 2021 milestone Aug 10, 2021
@TylerLeonhardt TylerLeonhardt self-assigned this Aug 10, 2021
@chrmarti
Copy link
Contributor

For testing could the QuickPick object have a triggerItemButton function that is not in the API interface and triggers the code for handling button clicks in the renderer? (Maybe that function could only be added when running in 'test' mode? If that's easily detectable.)

@TylerLeonhardt TylerLeonhardt merged commit 4191923 into main Aug 11, 2021
@TylerLeonhardt TylerLeonhardt deleted the TylerLeonhardt/add-quickpickitembutton-support branch August 11, 2021 15:42
@TylerLeonhardt TylerLeonhardt changed the title QuickQuickItem button API support QuickPickItem button API support Aug 11, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow "inline" menu contributions to quick pick items
2 participants