secondaryTap method

Future<DriveStep> secondaryTap(
  1. dynamic target, {
  2. Duration? settle,
})

A right-click — the mouse's other button, and the way a context menu is asked for on every desktop.

The synthetic mouse is moved there and clicks, which is what a mouse does and what onSecondaryTap is waiting for. It is the same pointer hover uses, so the click leaves the target hovered — a context menu that opens under the cursor sees the cursor where it should be — and unhover is what ends that.

Implementation

Future<DriveStep> secondaryTap(dynamic target, {Duration? settle}) {
  return _act('secondaryTap', target, settle, (finder) async {
    var at = _contact(target, finder);
    await controller.sendEventToBinding(_mouse.hover(at));
    _hovering = describeTarget(target);
    try {
      await controller.sendEventToBinding(
        _mouse.down(at, buttons: kSecondaryButton),
      );
    } finally {
      // A pointer left down wedges every later mouse verb — `TestPointer`
      // asserts a hover is only generated while it is up.
      if (_mouse.isDown) await controller.sendEventToBinding(_mouse.up());
    }
  });
}