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.
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.
Most helpful comment
In your
CustomNodeWidget, you have access to theengine. If you haven't, change yourCustomNodeFactoryto passthis.engineas a prop to your widget.Now, you can call
this.props.engine.fireEvent(event, 'myCustomListenerName'), whereeventis any object you want.To listen to this event: