React-diagrams: Make new custom listener for customNodeModel

Created on 3 Sep 2020  路  2Comments  路  Source: projectstorm/react-diagrams

Hey, can someone please tell me how can I make a custom event listener on my customNodeModel? I want this listener to fire when I right click on node.

Most helpful comment

In your CustomNodeWidget, you have access to the engine. If you haven't, change your CustomNodeFactory to pass this.engine as a prop to your widget.

Now, you can call this.props.engine.fireEvent(event, 'myCustomListenerName'), where event is any object you want.

To listen to this event:

engine.registerListener({
  myCustomListenerName: event => console.log('TODO: handle event', event),
})

All 2 comments

In your CustomNodeWidget, you have access to the engine. If you haven't, change your CustomNodeFactory to pass this.engine as a prop to your widget.

Now, you can call this.props.engine.fireEvent(event, 'myCustomListenerName'), where event is any object you want.

To listen to this event:

engine.registerListener({
  myCustomListenerName: event => console.log('TODO: handle event', event),
})

@renato-bohler Thanks man you saved my life it worked perfectly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schecter22107 picture schecter22107  路  3Comments

quangas picture quangas  路  3Comments

gugaevkirill picture gugaevkirill  路  3Comments

M2Costa picture M2Costa  路  3Comments

maxbasque picture maxbasque  路  3Comments