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


TypeScript messaging.MessageLoop类代码示例

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


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

示例1: it

 it('should focus on activation', () => {
   const content = new Widget();
   const widget = new MainAreaWidget({ content });
   Widget.attach(widget, document.body);
   MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
   expect(document.activeElement).to.equal(widget.content.node);
 });
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:7,代码来源:mainareawidget.spec.ts

示例2: activateCellTools

/**
 * Activate the cell tools extension.
 */
function activateCellTools(app: JupyterLab, tracker: INotebookTracker, editorServices: IEditorServices, state: IStateDB): Promise<ICellTools> {
  const id = 'cell-tools';
  const celltools = new CellTools({ tracker });
  const activeCellTool = new CellTools.ActiveCellTool();
  const slideShow = CellTools.createSlideShowSelector();
  const nbConvert = CellTools.createNBConvertSelector();
  const editorFactory = editorServices.factoryService.newInlineEditor;
  const metadataEditor = new CellTools.MetadataEditorTool({ editorFactory });

  // Create message hook for triggers to save to the database.
  const hook = (sender: any, message: Message): boolean => {
    switch (message.type) {
      case 'activate-request':
        state.save(id, { open: true });
        break;
      case 'after-hide':
      case 'close-request':
        state.remove(id);
        break;
      default:
        break;
    }
    return true;
  };

  celltools.title.label = 'Cell Tools';
  celltools.id = id;
  celltools.addItem({ tool: activeCellTool, rank: 1 });
  celltools.addItem({ tool: slideShow, rank: 2 });
  celltools.addItem({ tool: nbConvert, rank: 3 });
  celltools.addItem({ tool: metadataEditor, rank: 4 });
  MessageLoop.installMessageHook(celltools, hook);

  // Wait until the application has finished restoring before rendering.
  Promise.all([state.fetch(id), app.restored]).then(([args]) => {
    const open = !!(args && (args as ReadonlyJSONObject)['open'] as boolean);

    // After initial restoration, check if the cell tools should render.
    if (tracker.size) {
      app.shell.addToLeftArea(celltools);
      if (open) {
        app.shell.activateById(celltools.id);
      }
    }

    // For all subsequent widget changes, check if the cell tools should render.
    app.shell.currentChanged.connect((sender, args) => {
      // If there are any open notebooks, add cell tools to the side panel if
      // it is not already there.
      if (tracker.size) {
        if (!celltools.isAttached) {
          app.shell.addToLeftArea(celltools);
        }
        return;
      }
      // If there are no notebooks, close cell tools.
      celltools.close();
    });
  });

  return Promise.resolve(celltools);
}
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:65,代码来源:index.ts

示例3: sendMessageToParent

 private sendMessageToParent(msg: Message) {
   // direct parent is stacked panel of tab panel
   MessageLoop.sendMessage(this.parent!.parent, msg);
 }
开发者ID:twosigma,项目名称:beaker-notebook,代码行数:4,代码来源:JVMOptionsWidget.ts


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