convertEvent static method

WebPointerEvent convertEvent(
  1. dynamic context,
  2. dynamic event
)

Implementation

static WebPointerEvent convertEvent(context, event) {
  final wpe = WebPointerEvent();

  wpe.pointerId = event.pointer;
  wpe.pointerType = getPointerType(event);
  wpe.button = getButton(event);

  RenderBox getBox = context.findRenderObject() as RenderBox;
  final local = getBox.globalToLocal(event.position);
  wpe.clientX = local.dx;
  wpe.clientY = local.dy;
  wpe.pageX = event.position.dx;
  wpe.pageY = event.position.dy;

  if (event is PointerScrollEvent) {
    wpe.deltaX = event.scrollDelta.dx;
    wpe.deltaY = event.scrollDelta.dy;
  }
  final EventTouch touch = EventTouch();
  //if(event is PointerMoveEvent || event is PointerHoverEvent) {
    wpe.movementX = event.delta.dx;
    wpe.movementY = event.delta.dy;
  //}

  touch.pointer = event.pointer;
  touch.pageX = event.position.dx;
  touch.pageY = event.position.dy;
  touch.clientX = local.dx;
  touch.clientY = local.dy;

  wpe.touches.add(touch);
  wpe.changedTouches = [touch];

  return wpe;
}