retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

Unhandled Rejection (Error): The event multiselectnode does not exist #458

Closed benswinburne closed 1 year ago

benswinburne commented 4 years ago

I was trying to use the mutliselectnode event which admittedly doesn't appear to be documented but it seems to be in the codebase and I've seen it in a few responses to issues here.

However, I'm getting the error seen in the title when attaching this event to my editor.

  editor.on('multiselectnode', (nodes) => {
    console.log(nodes);
  });
    "rete": "^1.4.4",
    "rete-area-plugin": "0.2.1",
    "rete-auto-arrange-plugin": "^0.4.0",
    "rete-comment-plugin": "^0.7.0-rc.1",
    "rete-connection-path-plugin": "^0.3.1",
    "rete-connection-plugin": "0.7.2",
    "rete-dock-plugin": "^0.2.1",
    "rete-history-plugin": "^0.2.1",
    "rete-minimap-plugin": "^0.3.1",
    "rete-react-render-plugin": "0.2.0",
creadicted commented 4 years ago

@benswinburne I checked the code and only see the trigger executed here: https://github.com/retejs/rete/blob/88373184be4b6fda65048a0e262563bf87f7bbdf/src/view/node.ts#L77 I tested it locally and it will trigger on select. So I don't get the error. The result is exactly the same as if you check for selectnode.

    editor.on('selectnode', (nodes) => {
      console.log('selectnode', nodes);
    });

Is selectnode working? If you need your selections you can use editor.selected.list

benswinburne commented 4 years ago

@creadicted I'd come to the same conclusion and used another event. I also can't replicate the problem on codesandbox to show you now so I'll work out what might be different about my local copy.

I've used which is sufficient for now.

  editor.on('nodeselected', (node) => {
    options.setSelected([...editor.selected.list]);
  });

That said, it'd be nice if the multiselectnode event fired only when 1 or more nodes were selected and passed in [nodes] instead of just node perhaps.

I'll try and get this replicated and post later.

creadicted commented 4 years ago

That said, it'd be nice if the multiselectnode event fired only when 1 or more nodes were selected and passed in [nodes] instead of just node perhaps.

I added a Pullrequest. I would argue that mutliselectnode should be triggered if its higher than one. https://github.com/retejs/rete/pull/462

benswinburne commented 4 years ago

That's what I meant :) makes sense for multi when > 1 is selected, definitely.

rete-js[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.