How can I listen the element click event?

I want to capture/listen the element click event, I found this program CommandInterceptor can make it. There is some reason not working at all, only the shape.create event is workong properly.

The project on the codesandbox is here:
CommandInterceptor on CodeSandBox

Could someone make any suggestions here. I must miss something else. Thanks

For click events, you don’t need the CommandInterceptor. Those are only relevant when the state changes, such as adding/removing shapes.

If you just want to listen for element clicks, you can simply use the eventBus:

function MyExtension(eventBus) {
  eventBus.on("", (e) => console.log(e.element));

MyExtension.$inject = ["eventBus"];

export default {
  __init__: ["myExtension"],
  myExtension: ["type", MyExtension]

@Martin , Thanks your answer, it’s very clear.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.