简体   繁体   中英

Stop event propagation in Bonsai.js

How do I stop a mousedown event from propagating to the stage?

stage.addListener("pointerdown", startDrawing);

rect = Path.rect(x, y, 100, 100);
stage.addChild rect;

rect.addListener("pointerdown", selectHandler);

startDrawing gets called each time after selectHandler

Curiously though, I had the answer to the question all along, was just tricked into thinking it wasn't working.

Stop the event in the selectHandler:

function selectHandler(e) {
  e.stop();
};

PS You can see my work in progress here: http://codepen.io/zinkkrysty/pen/iyrjG?editors=001

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM