当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript menu.Menu类代码示例

本文整理汇总了TypeScript中phosphor/lib/ui/menu.Menu的典型用法代码示例。如果您正苦于以下问题:TypeScript Menu类的具体用法?TypeScript Menu怎么用?TypeScript Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Menu类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: DisposableSet

  node.addEventListener('contextmenu', (event: MouseEvent) => {
    event.preventDefault();
    let path = fbWidget.pathForClick(event) || '';
    let ext = '.' + path.split('.').pop();
    let widgetNames = registry.listWidgetFactories(ext);
    let prefix = `file-browser-contextmenu-${++Private.id}`;
    let openWith: Menu = null;
    if (path && widgetNames.length > 1) {
      let disposables = new DisposableSet();
      let command: string;

      openWith = new Menu({ commands, keymap });
      openWith.title.label = 'Open With...';
      openWith.disposed.connect(() => disposables.dispose());

      for (let widgetName of widgetNames) {
        command = `${prefix}:${widgetName}`;
        disposables.add(commands.addCommand(command, {
          execute: () => fbWidget.openPath(path, widgetName),
          label: widgetName
        }));
        openWith.addItem({ command });
      }
    }

    let menu = createContextMenu(fbWidget, openWith);
    menu.open(event.clientX, event.clientY);
  });
开发者ID:recoveringMathmo,项目名称:jupyterlab,代码行数:28,代码来源:plugin.ts

示例2: createMenu

  function createMenu(app: JupyterLab): Menu {
    let { commands, keymap } = app;
    let menu = new Menu({ commands, keymap });
    menu.title.label = 'Help';
    menu.addItem({ command: 'about-jupyterlab:show' });
    menu.addItem({ command: 'faq-jupyterlab:show' });

    COMMANDS.forEach(item => menu.addItem({ command: item.id }));
    return menu;
  }
开发者ID:dmadeka,项目名称:jupyterlab,代码行数:10,代码来源:plugin.ts

示例3: createMenu

/**
 * Create a menu for the editor.
 */
function createMenu(app: JupyterLab): Menu {
  const { commands, keymap } = app;
  const menu = new Menu({ commands, keymap });
  menu.title.label = 'Editor';

  menu.addItem({ command: 'file-operations:new-text-file' });
  menu.addItem({ command: 'file-operations:save' });
  menu.addItem({ command: cmdIds.closeAll });
  menu.addItem({ type: 'separator' });

  return menu;
}
开发者ID:TypeFox,项目名称:jupyterlab,代码行数:15,代码来源:plugin.ts

示例4: createMenu

  /**
   * Create a menu for the help plugin.
   */
  function createMenu(): Menu {
    let { commands, keymap } = app;
    let menu = new Menu({ commands, keymap });
    menu.title.label = category;

    menu.addItem({ command: 'about-jupyterlab:show' });
    menu.addItem({ command: 'faq-jupyterlab:show' });
    menu.addItem({ command: 'classic-notebook:open' });

    COMMANDS.forEach(item => menu.addItem({ command: item.id }));

    menu.addItem({ command: 'statedb:clear' });

    return menu;
  }
开发者ID:danielballan,项目名称:jupyterlab,代码行数:18,代码来源:plugin.ts

示例5: createMenu

  /**
   * Create a menu for the help plugin.
   */
  function createMenu(): Menu {
    let { commands, keymap } = app;
    let menu = new Menu({ commands, keymap });
    menu.title.label = category;

    menu.addItem({ command: 'about-jupyterlab:show' });
    menu.addItem({ command: 'faq-jupyterlab:show' });
    menu.addItem({ command: 'classic-notebook:open' });

    RESOURCES.forEach(args => { menu.addItem({ args, command }); });

    menu.addItem({ command: 'statedb:clear' });

    return menu;
  }
开发者ID:fperez,项目名称:jupyterlab,代码行数:18,代码来源:plugin.ts

示例6: createMenu

/**
 * Create a menu for the editor.
 */
function createMenu(app: JupyterLab, tracker: IEditorTracker): Menu {
  let { commands, keymap } = app;
  let settings = new Menu({ commands, keymap });
  let theme = new Menu({ commands, keymap });
  let menu = new Menu({ commands, keymap });

  menu.title.label = 'Editor';
  settings.title.label = 'Settings';
  theme.title.label = 'Theme';

  settings.addItem({ command: cmdIds.lineNumbers });
  settings.addItem({ command: cmdIds.lineWrap });
  settings.addItem({ command: cmdIds.matchBrackets });
  settings.addItem({ command: cmdIds.vimMode });

  commands.addCommand(cmdIds.changeTheme, {
    label: args => {
      return args['theme'] as string;
    },
    execute: args => {
      let name: string = args['theme'] as string || DEFAULT_CODEMIRROR_THEME;
      each(tracker.widgets, widget => {
        widget.editor.setOption('theme', name);
      });
    }
  });

  [
   'jupyter', 'default', 'abcdef', 'base16-dark', 'base16-light',
   'hopscotch', 'material', 'mbo', 'mdn-like', 'seti', 'the-matrix',
   'xq-light', 'zenburn'
  ].forEach(name => theme.addItem({
    command: 'editor:change-theme',
    args: { theme: name }
  }));

  menu.addItem({ command: cmdIds.closeAll });
  menu.addItem({ type: 'separator' });
  menu.addItem({ type: 'submenu', menu: settings });
  menu.addItem({ type: 'submenu', menu: theme });

  return menu;
}
开发者ID:aggFTW,项目名称:jupyterlab,代码行数:46,代码来源:plugin.ts

示例7: createMenu

  /**
   * Create a menu for the editor.
   */
  function createMenu(): Menu {
    let settings = new Menu({ commands, keymap });
    let theme = new Menu({ commands, keymap });
    let menu = new Menu({ commands, keymap });

    menu.title.label = 'Editor';
    settings.title.label = 'Settings';
    theme.title.label = 'Theme';

    settings.addItem({ command: cmdIds.lineNumbers });
    settings.addItem({ command: cmdIds.lineWrap });
    settings.addItem({ command: cmdIds.matchBrackets });
    settings.addItem({ command: cmdIds.vimMode });

    commands.addCommand(cmdIds.changeTheme, {
      label: args => args['theme'] as string,
      execute: args => {
        let name: string = args['theme'] as string || CodeMirrorEditor.DEFAULT_THEME;
        tracker.forEach(widget => {
          if (widget.editor instanceof CodeMirrorEditor) {
            let cm = widget.editor.editor;
            cm.setOption('theme', name);
          }
        });
      }
    });

    [
     'jupyter', 'default', 'abcdef', 'base16-dark', 'base16-light',
     'hopscotch', 'material', 'mbo', 'mdn-like', 'seti', 'the-matrix',
     'xq-light', 'zenburn'
    ].forEach(name => theme.addItem({
      command: 'editor:change-theme',
      args: { theme: name }
    }));

    menu.addItem({ type: 'separator' });
    menu.addItem({ type: 'submenu', menu: settings });
    menu.addItem({ type: 'submenu', menu: theme });

    return menu;
  }
开发者ID:Carreau,项目名称:jupyterlab,代码行数:45,代码来源:plugin.ts

示例8: createApp


//.........这里部分代码省略.........
    execute: () => {
      let context = docManager.contextForWidget(activeWidget);
      context.save();
    }
  });
  commands.addCommand('file-cut', {
    label: 'Cut',
    icon: 'fa fa-cut',
    execute: () => { fbWidget.cut(); }
  });
  commands.addCommand('file-copy', {
    label: 'Copy',
    icon: 'fa fa-copy',
    mnemonic: 0,
    execute: () => { fbWidget.copy(); }
  });
  commands.addCommand('file-delete', {
    label: 'Delete',
    icon: 'fa fa-remove',
    mnemonic: 0,
    execute: () => { fbWidget.delete(); }
  });
  commands.addCommand('file-duplicate', {
    label: 'Duplicate',
    icon: 'fa fa-copy',
    mnemonic: 0,
    execute: () => { fbWidget.duplicate(); }
  });
  commands.addCommand('file-paste', {
    label: 'Paste',
    icon: 'fa fa-paste',
    mnemonic: 0,
    execute: () => { fbWidget.paste(); }
  });
  commands.addCommand('file-download', {
    label: 'Download',
    icon: 'fa fa-download',
    execute: () => { fbWidget.download(); }
  });
  commands.addCommand('file-shutdown-kernel', {
    label: 'Shutdown Kernel',
    icon: 'fa fa-stop-circle-o',
    execute: () => { fbWidget.shutdownKernels(); }
  });
  commands.addCommand('file-dialog-demo', {
    label: 'Dialog Demo',
    execute: () => { dialogDemo(); }
  });
  commands.addCommand('file-info-demo', {
    label: 'Info Demo',
    execute: () => {
      let msg = 'The quick brown fox jumped over the lazy dog';
      showDialog({
        title: 'Cool Title',
        body: msg,
        buttons: [okButton]
      });
    }
  });

  keymap.addBinding({
    keys: ['Enter'],
    selector: '.jp-DirListing',
    command: 'file-open'
  });
  keymap.addBinding({
    keys: ['Accel S'],
    selector: '.jp-CodeMirrorWidget',
    command: 'file-save'
  });
  window.addEventListener('keydown', (event) => {
    keymap.processKeydownEvent(event);
  });

  let menu = new Menu({ commands, keymap });
  menu.addItem({ command: 'file-open' });
  menu.addItem({ command: 'file-rename' });
  menu.addItem({ command: 'file-remove' });
  menu.addItem({ command: 'file-duplicate' });
  menu.addItem({ command: 'file-delete' });
  menu.addItem({ command: 'file-cut' });
  menu.addItem({ command: 'file-copy' });
  menu.addItem({ command: 'file-paste' });
  menu.addItem({ command: 'file-shutdown-kernel' });
  menu.addItem({ command: 'file-dialog-demo' });
  menu.addItem({ command: 'file-info-demo' });

  // Add a context menu to the dir listing.
  let node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
  node.addEventListener('contextmenu', (event: MouseEvent) => {
    event.preventDefault();
    let x = event.clientX;
    let y = event.clientY;
    menu.open(x, y);
  });

  Widget.attach(panel, document.body);

  window.onresize = () => panel.update();
}
开发者ID:fperez,项目名称:jupyterlab,代码行数:101,代码来源:index.ts


注:本文中的phosphor/lib/ui/menu.Menu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。