-1

That is the thing, i'm creating a shape that covers all canvas to act like a white background, i have a transformer and im listening to canvas clicks, inside it im adding objects into transformer nodes, but i don't like to transform the white shape that im using as a background.

Canvas white Shape

dcruz1990
  • 1
  • 2

1 Answers1

0

Just don't add transformer into it. I see several solutions:

  1. Set listening = false on that background shape. In that case, it will not trigger any mouse/touch/pointer events
  2. Or set a special name for it in just ignore in click callback
const background = new Konva.Rect({
  fill: 'white',
  width: stage.width(),
  height: stage.height(),
  name: 'nonSelectable'
});



stage.on('click', (e) => {
  // ignore such shape
  if (e.target.hasName('nonSelectable')) {
    return;
  }
  // else attach transformer
});
lavrton
  • 18,973
  • 4
  • 30
  • 63