emulateTouchFromMouseEvent method

Future<void> emulateTouchFromMouseEvent(
  1. @Enum(['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel']) String type,
  2. int x,
  3. int y,
  4. MouseButton button, {
  5. TimeSinceEpoch? timestamp,
  6. num? deltaX,
  7. num? deltaY,
  8. int? modifiers,
  9. int? clickCount,
})

Emulates touch event from the mouse event parameters. type Type of the mouse event. x X coordinate of the mouse pointer in DIP. y Y coordinate of the mouse pointer in DIP. button Mouse button. Only "none", "left", "right" are supported. timestamp Time at which the event occurred (default: current time). deltaX X delta in DIP for mouse wheel event (default: 0). deltaY Y delta in DIP for mouse wheel event (default: 0). modifiers Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). clickCount Number of times the mouse button was clicked (default: 0).

Implementation

Future<void> emulateTouchFromMouseEvent(
    @Enum(['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel'])
    String type,
    int x,
    int y,
    MouseButton button,
    {TimeSinceEpoch? timestamp,
    num? deltaX,
    num? deltaY,
    int? modifiers,
    int? clickCount}) async {
  assert(const ['mousePressed', 'mouseReleased', 'mouseMoved', 'mouseWheel']
      .contains(type));
  await _client.send('Input.emulateTouchFromMouseEvent', {
    'type': type,
    'x': x,
    'y': y,
    'button': button,
    if (timestamp != null) 'timestamp': timestamp,
    if (deltaX != null) 'deltaX': deltaX,
    if (deltaY != null) 'deltaY': deltaY,
    if (modifiers != null) 'modifiers': modifiers,
    if (clickCount != null) 'clickCount': clickCount,
  });
}