How to use the @lumino/widgets.Widget.Msg function in @lumino/widgets

To help you get started, we’ve selected a few @lumino/widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-notebook / src / widget.spec.ts View on Github external
it('should unrender a markdown cell when switching to edit mode', () => {
        const widget = createActiveWidget();
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
        const cell = widget.model!.contentFactory.createMarkdownCell({});
        cell.value.text = '# Hello'; // Should be rendered with content.
        widget.model!.cells.push(cell);
        const child = widget.widgets[widget.widgets.length - 1] as MarkdownCell;
        expect(child.rendered).to.equal(true);
        widget.activeCellIndex = widget.widgets.length - 1;
        widget.mode = 'edit';
        expect(child.rendered).to.equal(false);
      });
    });
github jupyterlab / jupyterlab / packages / apputils / src / dialog.ts View on Github external
createBody(value: Body): Widget {
      let body: Widget;
      if (typeof value === 'string') {
        body = new Widget({ node: document.createElement('span') });
        body.node.textContent = value;
      } else if (value instanceof Widget) {
        body = value;
      } else {
        body = ReactWidget.create(value);
        // Immediately update the body even though it has not yet attached in
        // order to trigger a render of the DOM nodes from the React element.
        MessageLoop.sendMessage(body, Widget.Msg.UpdateRequest);
      }
      body.addClass('jp-Dialog-body');
      Styling.styleNode(body.node);
      return body;
    }
github jupyterlab / jupyterlab / tests / test-console / src / panel.spec.ts View on Github external
it('should give the focus to the console prompt', () => {
        expect(panel.methods).to.not.contain('onActivateRequest');
        Widget.attach(panel, document.body);
        MessageLoop.sendMessage(panel, Widget.Msg.ActivateRequest);
        expect(panel.methods).to.contain('onActivateRequest');
        expect(panel.console.promptCell.editor.hasFocus()).to.equal(true);
        return dismissDialog();
      });
    });
github jupyterlab / jupyterlab / tests / test-console / src / widget.spec.ts View on Github external
it('should focus the prompt editor', () => {
        expect(widget.promptCell).to.not.be.ok;
        expect(widget.methods).to.not.contain('onActivateRequest');
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
        expect(widget.methods).to.contain('onActivateRequest');
        expect(widget.promptCell.editor.hasFocus()).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-fileeditor / src / widget.spec.ts View on Github external
it('should focus the node after an update', async () => {
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
        expect(widget.methods).to.contain('onActivateRequest');
        await framePromise();
        expect(widget.editor.hasFocus()).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-imageviewer / src / widget.spec.ts View on Github external
it('should set the content after the context is ready', async () => {
      await context.ready;
      MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
      const img = widget.node.querySelector('img') as HTMLImageElement;
      expect(img.src).to.contain(IMAGE.content);
    });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / widget.spec.ts View on Github external
it('should focus the editor', () => {
      Widget.attach(widget, document.body);
      MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
      expect(widget.methods).to.contain('onActivateRequest');
      expect(widget.editor.hasFocus()).to.be.true;
    });
  });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should accept options with a renderer', () => {
        let options: Completer.IOptions = {
          editor: null,
          model: new CompleterModel(),
          renderer: new CustomRenderer()
        };
        options.model!.setOptions(['foo', 'bar']);

        let widget = new Completer(options);
        expect(widget).to.be.an.instanceof(Completer);
        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);

        let items = widget.node.querySelectorAll(`.${ITEM_CLASS}`);
        expect(items).to.have.length(2);
        expect(Array.from(items[0].classList)).to.contain(TEST_ITEM_CLASS);
      });
    });
github jupyterlab / jupyterlab / tests / test-terminal / src / terminal.spec.ts View on Github external
it('should handle fit requests', () => {
        widget.processMessage(Widget.Msg.FitRequest);
        expect(widget.methods).to.contain('onFitRequest');
      });
    });
github jupyterlab / jupyterlab / tests / test-cells / src / widget.spec.ts View on Github external
it('should update the widget', () => {
        const widget = new LogCodeCell().initializeState();
        expect(widget.methods).not.toContain('onUpdateRequest');
        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
        expect(widget.methods).toContain('onUpdateRequest');
      });
    });