Skip to content

Mouse#move omits button: on mouseMoved, so drags never start #635

Description

@myabc

🤖 Filed by an agent on my behalf.

Ferrum::Mouse#move sends the buttons bitmask but not button:, so Chrome never treats a held-button move as a drag gesture. No native drag session starts, and with Input.setInterceptDrags(true) enabled, Input.dragIntercepted never fires — which makes CDP-based HTML5 drag-and-drop impossible to build on top of Ferrum today.

lib/ferrum/mouse.rb:

@page.command("Input.dispatchMouseEvent",
              slowmoable: true,
              type: "mouseMoved",
              x: new_x,
              y: new_y,
              buttons: @buttons)   # no `button:`

Minimal repro, identical apart from that one field:

page.command("Input.setInterceptDrags", enabled: true)
page.on("Input.dragIntercepted") { |params, _i, _t| got.set(params["data"]) }

page.command("Input.dispatchMouseEvent", type: "mousePressed", x: sx, y: sy,
                                         button: "left", buttons: 1, clickCount: 1)
5.times do |i|
  page.command("Input.dispatchMouseEvent", type: "mouseMoved", x: sx, y: sy + ((i + 1) * 6),
                                           button: "left", buttons: 1)
end
with    button: "left"  ->  intercepted: YES  ->  dragstart, dragenter, dragover, drop, dragend
without button: "left"  ->  intercepted: NO   ->  no events at all

The second form is what Mouse#move currently emits after Mouse#down.

Chrome 140, Ferrum 0.18.0.

Sending button alongside buttons whenever a button is held looks sufficient. Happy to open a PR if that is the shape you'd want.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions