• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript widgets.Menu类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: toArray

  node.addEventListener('contextmenu', (event: MouseEvent) => {
    event.preventDefault();
    let path = fbWidget.pathForClick(event) || '';
    let ext = DocumentRegistry.extname(path);
    let factories = registry.preferredWidgetFactories(ext);
    let widgetNames = toArray(map(factories, factory => factory.name));
    let prefix = `${namespace}-contextmenu-${++Private.id}`;
    let openWith: Menu = null;
    if (path && widgetNames.length > 1) {
      let disposables = new DisposableSet();
      let command: string;

      openWith = new Menu({ commands });
      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:samvasko,项目名称:jupyterlab,代码行数:29,代码来源:index.ts


示例2: Menu

  activate: (
    app: JupyterFrontEnd,
    statusBar: IStatusBar,
    editorTracker: IEditorTracker,
    settingRegistry: ISettingRegistry
  ) => {
    // Create a menu for switching tabs vs spaces.
    const menu = new Menu({ commands: app.commands });
    const command = 'fileeditor:change-tabs';
    const { shell } = app;
    const args: JSONObject = {
      insertSpaces: false,
      size: 4,
      name: 'Indent with Tab'
    };
    menu.addItem({ command, args });
    for (let size of [1, 2, 4, 8]) {
      let args: JSONObject = {
        insertSpaces: true,
        size,
        name: `Spaces: ${size} `
      };
      menu.addItem({ command, args });
    }

    // Create the status item.
    const item = new TabSpaceStatus({ menu });

    // Keep a reference to the code editor config from the settings system.
    const updateSettings = (settings: ISettingRegistry.ISettings): void => {
      const cached = settings.get('editorConfig').composite as Partial<
        CodeEditor.IConfig
      >;
      const config: CodeEditor.IConfig = {
        ...CodeEditor.defaultConfig,
        ...cached
      };
      item.model!.config = config;
    };
    void Promise.all([
      settingRegistry.load('@jupyterlab/fileeditor-extension:plugin'),
      app.restored
    ]).then(([settings]) => {
      updateSettings(settings);
      settings.changed.connect(updateSettings);
    });

    // Add the status item.
    statusBar.registerStatusItem(
      '@jupyterlab/fileeditor-extension:tab-space-status',
      {
        item,
        align: 'right',
        rank: 1,
        isActive: () => {
          return shell.currentWidget && editorTracker.has(shell.currentWidget);
        }
      }
    );
  }
开发者ID:alexmorley,项目名称:jupyterlab,代码行数:60,代码来源:index.ts


示例3: createMenu

/**
 * Create a top level menu for the file browser.
 */
function createMenu(app: JupyterLab): Menu {
  const { commands } = app;
  const menu = new Menu({ commands });

  menu.title.label = 'File';
  [
    CommandIDs.createLauncher,
    'docmanager:save',
    'docmanager:save-as',
    'docmanager:rename',
    'docmanager:restore-checkpoint',
    'docmanager:clone',
    'docmanager:close',
    'docmanager:close-all-files'
  ].forEach(command => { menu.addItem({ command }); });
  menu.addItem({ type: 'separator' });
  menu.addItem({ command: 'settingeditor:open' });

  return menu;
}
开发者ID:sccolbert,项目名称:jupyterlab,代码行数:23,代码来源:index.ts


示例4: createMenu

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

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

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

    commands.addCommand(CommandIDs.changeTheme, {
      label: args => args['theme'] as string,
      execute: args => {
        let name = 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', submenu: settings });
    menu.addItem({ type: 'submenu', submenu: theme });

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


示例5: createMenu

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

    menu.addItem({ command: 'about-jupyterlab:open' });
    menu.addItem({ command: 'faq-jupyterlab:open' });
    menu.addItem({ command: CommandIDs.launchClassic });
    menu.addItem({ type: 'separator' });
    RESOURCES.forEach(args => { menu.addItem({ args, command }); });
    menu.addItem({ type: 'separator' });
    menu.addItem({ command: 'statedb:clear' });

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


示例6: return

		return () => {
			commands.addCommand("cut", {
				label: "Cut",
				mnemonic: 1,
				icon: "fa fa-cut",
				execute: () => {
					console.log("Cut");
				}
			});

			commands.addCommand("copy", {
				label: "Copy File",
				mnemonic: 0,
				icon: "fa fa-copy",
				execute: () => {
					console.log("Copy");
				}
			});

			commands.addCommand("paste", {
				label: "Paste",
				mnemonic: 0,
				icon: "fa fa-paste",
				execute: () => {
					console.log("Paste");
				}
			});

			commands.addCommand("new-tab", {
				label: "New Tab",
				mnemonic: 0,
				caption: "Open a new tab",
				icon: "fa fa-plus",
				execute: () => {
					let content = new Content("New");
					dock.addWidget(content);
				}
			});

			commands.addCommand("close", {
				label: "Close",
				mnemonic: 0,
				icon: "fa fa-close",
				execute: () => {
					console.log("Close");
				}
			});

			commands.addCommand("default-theme", {
				label: "Default theme",
				mnemonic: 0,
				icon: "fa fa-paint-brush",
				execute: () => {
					console.log("Default theme");
				}
			});

			commands.addCommand("clean-theme", {
				label: "Clean theme",
				mnemonic: 0,
				icon: "fa fa-tint",
				execute: () => {
					console.log("Clean theme");
				}
			});

			commands.addCommand("dark-toggle", {
				label: "Toggle",
				mnemonic: 0,
				icon: "fa fa-plus",
				execute: () => {
					document.body.classList.toggle("--dark");
				}
			});

			let menu1 = new Menu({commands});
			menu1.title.label = "File";
			menu1.title.mnemonic = 0;
			menu1.addItem({command: "new-tab"});
			menu1.addItem({type: "separator"});
			menu1.addItem({command: "close"});

			let menu2 = new Menu({commands});
			menu2.title.label = "Theme";
			menu2.title.mnemonic = 0;
			menu2.addItem({command: "default-theme"});
			menu2.addItem({command: "clean-theme"});

			let ctxt = new Menu({commands});
			ctxt.addItem({command: "copy"});
			ctxt.addItem({command: "cut"});
			ctxt.addItem({command: "paste"});

			let bar = new MenuBar();
			bar.addMenu(menu1);
			bar.addMenu(menu2);
			bar.id = "menuBar";

			let toggle = new Toggle({onLabel: "Dark", offLabel: "Light", command: "dark-toggle", commands: commands});
			toggle.id = "daylightToggle";
//.........这里部分代码省略.........
开发者ID:ermalism,项目名称:phosphorjs-react-jsx-example,代码行数:101,代码来源:index.ts


示例7: createContextMenu

/**
 * Create a context menu for the file browser listing.
 *
 * #### Notes
 * This function generates temporary commands with an incremented name. These
 * commands are disposed when the menu itself is disposed.
 */
function createContextMenu(model: Contents.IModel, commands: CommandRegistry, registry: DocumentRegistry): Menu {
  const path = model.path;
  const menu = new Menu({ commands });

  menu.addItem({ command: CommandIDs.open });

  if (model.type !== 'directory') {
    const factories = registry.preferredWidgetFactories(path).map(f => f.name);
    if (path && factories.length > 1) {
      const command =  'docmanager:open';
      const openWith = new Menu({ commands });
      openWith.title.label = 'Open With';
      factories.forEach(factory => {
        openWith.addItem({ args: { factory, path }, command });
      });
      menu.addItem({ type: 'submenu', submenu: openWith });
    }
  }

  menu.addItem({ command: CommandIDs.rename });
  menu.addItem({ command: CommandIDs.del });
  menu.addItem({ command: CommandIDs.cut });

  if (model.type !== 'directory') {
    menu.addItem({ command: CommandIDs.copy });
  }

  menu.addItem({ command: CommandIDs.paste });

  if (model.type !== 'directory') {
    menu.addItem({ command: CommandIDs.duplicate });
    menu.addItem({ command: CommandIDs.download });
    menu.addItem({ command: CommandIDs.shutdown });
  }

  menu.addItem({ command: CommandIDs.share });

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


示例8: each

 each(registry.creators(), creator => {
   const command = CommandIDs.createFrom;
   const creatorName = creator.name;
   const label = `New ${creatorName}`;
   const args = { creatorName, label };
   menu.insertItem(0, { args, command });
   Private.creators.add(palette.addItem({ args, category, command }));
 });
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:8,代码来源:index.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript widgets.Panel类代码示例发布时间:2022-05-28
下一篇:
TypeScript widgets.DockPanel类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap