rete icon indicating copy to clipboard operation
rete copied to clipboard

Electron context menu causes retejs's canvas to stop responding to mouse movement on MacOS

Open AydanGaite opened this issue 5 years ago • 0 comments

I'm attempting to use electrons native context menu to give options to clone and delete nodes, but whenever I trigger the context menu, the rete canvas stops responding to mouse events. The modules still move, but I loose the ability to navigate the canvas.

Here is my code: `this.editor.on("contextmenu", async ({ node }) => { const menu = new Menu();

  if (node) {
    // Create clone entity
    menu.append(
      new MenuItem({
        label: "Clone",
        click: async () => {
          const {
            name,
            position: [x, y],
            ...params
          } = node;

          const component = this.editor.components.get(name);
          const newNode = await this.createNode(component, {
            ...params,
            x: x + 10,
            y: y + 10,
          });

          this.editor.addNode(newNode);
        },
      })
    );
    menu.append(new MenuItem({ type: "separator" }));
    // Delete entity
    menu.append(
      new MenuItem({
        label: "Delete",
        click: () => {
          this.editor.removeNode(node);
        },
      })
    );
  } else {
    menu.append(
      new MenuItem({
        label: "Add Component",
        click: () => {
          const panel = f7.panel.get("right");
          panel.open(true);
        },
      })
    );
  }

  menu.popup({ window: remote.getCurrentWindow() });
});`

AydanGaite avatar Jan 30 '21 22:01 AydanGaite