當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CommandRegistry.addKeyBinding方法代碼示例

本文整理匯總了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);
 });
開發者ID:afshin,項目名稱:phosphor,代碼行數:25,代碼來源:index.spec.ts

示例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());
開發者ID:blink1073,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts

示例3: normalizeOptions

    disposables = shortcuts.reduce((acc, val): DisposableSet => {
      const options = normalizeOptions(val);

      if (options) {
        acc.add(commands.addKeyBinding(options));
      }

      return acc;
    }, new DisposableSet());
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:9,代碼來源:index.ts


注:本文中的@phosphor/commands.CommandRegistry.addKeyBinding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。