Ejemplo n.º 1
0
/*
 * Generate the down click part of an arbitrary click event
 *
 * This might be useful in concert with {Mouse.arbitrary_click_up} if
 * you want to inject some behaviour between the down and up click
 * events.
 *
 * You can optionally specify a point to click; the mouse cursor will
 * instantly jump to the given point; otherwise the click event happens
 * at the current cursor position.
 *
 * @overload arbitrary_click_down()
 *   @return [CGPoint]
 * @overload arbitrary_click_down(point)
 *   @param point [CGPoint]
 *   @return [CGPoint]
 */
static
VALUE
rb_mouse_arbitrary_click_down(const int argc,
                              VALUE* const argv,
                              UNUSED const VALUE self)
{
    if (argc == 0)
        rb_raise(rb_eArgError,
                 "arbitrary_click_down requires at least one arg");

    const uint_t button = NUM2UINT(argv[0]);

    switch (argc) {
    case 1:
        mouse_arbitrary_click_down(button);
        break;
    case 2:
    default:
        mouse_arbitrary_click_down2(button, rb_mouse_unwrap_point(argv[1]));
    }

    return CURRENT_POSITION;
}
Ejemplo n.º 2
0
void
mouse_arbitrary_click(CGEventMouseSubtype button)
{
  mouse_arbitrary_click_down(button);
  mouse_arbitrary_click_up(button);
}