/* * @note Scrolling by `:pixel` may not actually be by real pixels, but instead * correspond to Cocoa co-ords (I don't have a retina display, so I haven't * checked it out yet). * * Generate `amount` of horizontal scroll events at the current cursor position * * Returns number of lines/pixels scrolled, default `units` are by `line`. * A positive `amount` will scroll up and a negative `amount` will scroll down. * * An animation duration can also be specified, which defaults to 0.2 seconds. * * @overload horizontal_scroll(amount) * @param amount [Number] * @return [Number] * @overload horizontal_scroll(amount, units) * @param amount [Number] * @param units [Symbol] `:pixel` or `:line` * @return [Number] * @overload horizontal_scroll(amount, units, duration) * @param amount [Number] * @param units [Symbol] `:pixel` or `:line` * @param duration [Number] animation time, in seconds * @return [Number] */ static VALUE rb_mouse_horizontal_scroll(const int argc, VALUE* const argv, UNUSED const VALUE self) { if (argc == 0 || argc > 3) rb_raise(rb_eArgError, "scroll requires 1..3 arguments, you gave %d", argc); const int amt = NUM2INT(argv[0]); if (argc == 1) { mouse_horizontal_scroll(amt); } else { const VALUE input_units = argv[1]; CGScrollEventUnit units = kCGScrollEventUnitLine; if (input_units == sym_pixel) units = kCGScrollEventUnitPixel; else if (input_units == sym_line) units = kCGScrollEventUnitLine; else rb_raise(rb_eArgError, "unknown units `%s'", rb_id2name(SYM2ID(input_units))); if (argc == 2) mouse_horizontal_scroll2(amt, units); else mouse_horizontal_scroll3(amt, units, NUM2DBL(argv[2])); } return argv[0]; }
void mouse_horizontal_scroll(int amount) { mouse_horizontal_scroll2(amount, kCGScrollEventUnitLine); }