bindEventListeners method

  1. @override
void bindEventListeners()
override

Implementation

@override
void bindEventListeners() {
  draggedListener = addEventListener(EventType.mouseDraggedEvent, (event) {
    if (isDragged) {
      mobject.moveToPoint(event.mousePos);

      onDrag(event.mousePos);

      return true; // handle the event
    }

    return false;
  });

  pressedListener = addEventListener(EventType.mousePressedEvent, (event) {
    var inside = mobject.isInside(event.mousePos);
    if (inside) {
      isDragged = true;
      mobject.moveToPoint(event.mousePos);

      return true; // handle the event
    }

    return false;
  });

  releasedListener = addEventListener(EventType.mouseReleasedEvent, (event) {
    isDragged = false;
    return false;
  });
}