本文整理匯總了TypeScript中vs/platform/actions/common/actions.MenuRegistry.getMenuItems方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript MenuRegistry.getMenuItems方法的具體用法?TypeScript MenuRegistry.getMenuItems怎麽用?TypeScript MenuRegistry.getMenuItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/platform/actions/common/actions.MenuRegistry
的用法示例。
在下文中一共展示了MenuRegistry.getMenuItems方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('special MenuId palette', function () {
disposables.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: { id: 'a', title: 'Explicit' }
}));
MenuRegistry.addCommand({ id: 'b', title: 'Implicit' });
let foundA = false;
let foundB = false;
for (const item of MenuRegistry.getMenuItems(MenuId.CommandPalette)) {
if (isIMenuItem(item)) {
if (item.command.id === 'a') {
assert.equal(item.command.title, 'Explicit');
foundA = true;
}
if (item.command.id === 'b') {
assert.equal(item.command.title, 'Implicit');
foundB = true;
}
}
}
assert.equal(foundA, true);
assert.equal(foundB, true);
});
示例2: test
test('special MenuId palette', function () {
disposables.push(MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: { id: 'a', title: 'Explicit' }
}));
MenuRegistry.addCommand({ id: 'b', title: 'Implicit' });
const [first, second] = MenuRegistry.getMenuItems(MenuId.CommandPalette);
assert.equal(first.command.id, 'a');
assert.equal(first.command.title, 'Explicit');
assert.equal(second.command.id, 'b');
assert.equal(second.command.title, 'Implicit');
});