本文整理匯總了TypeScript中@phosphor/commands.CommandRegistry.addKeyBinding方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommandRegistry.addKeyBinding方法的具體用法?TypeScript CommandRegistry.addKeyBinding怎麽用?TypeScript CommandRegistry.addKeyBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@phosphor/commands.CommandRegistry
的用法示例。
在下文中一共展示了CommandRegistry.addKeyBinding方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should pick the selector with greater specificity', () => {
elem.classList.add('test');
let called1 = false;
let called2 = false;
registry.addCommand('test1', {
execute: () => { called1 = true; }
});
registry.addCommand('test2', {
execute: () => { called2 = true; }
});
registry.addKeyBinding({
keys: ['Ctrl ;'],
selector: '.test',
command: 'test1'
});
registry.addKeyBinding({
keys: ['Ctrl ;'],
selector: `#${elem.id}`,
command: 'test2'
});
let event = generate('keydown', { keyCode: 59, ctrlKey: true });
elem.dispatchEvent(event);
expect(called1).to.equal(false);
expect(called2).to.equal(true);
});
示例2: normalizeOptions
disposables = Object.keys(composite).reduce((acc, val): DisposableSet => {
const options = normalizeOptions(composite[val]);
if (options) {
acc.add(commands.addKeyBinding(options));
}
return acc;
}, new DisposableSet());
示例3: normalizeOptions
disposables = shortcuts.reduce((acc, val): DisposableSet => {
const options = normalizeOptions(val);
if (options) {
acc.add(commands.addKeyBinding(options));
}
return acc;
}, new DisposableSet());