chromedp / pdlgen

Generates templated code using Chrome DevTools PDL definitions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DispatchMouseEvent does not support mouseWheel along one axis

wtsuench opened this issue · comments

chromedp/chromedp#491

What versions are you running?

$ go list -m github.com/chromedp/chromedp
$ google-chrome --version
$ go version
github.com/chromedp/chromedp
Version 77.0.3865.90
go version go1.12.7 darwin/amd64

What did you do? Include clear steps.
I'm trying to implement the mouseWheel event,

p := input.DispatchMouseEvent(input.MouseWheel, 0, 0)
p = p.WithDeltaX(0)
p = p.WithDeltaY(float64(y))
err = p.Do(ctx)
without scrolling along the x-axis p.WithDeltaX(0).

What did you expect to see?
MouseWheel event triggered and webpage scrolls to y, without scrolling x.

What did you see instead?
Error 'deltaX' and 'deltaY' are expected for mouseWheel event (-32602)

Confusion?
Can we not scroll y without x?

type DispatchMouseEventParams struct {
	Type        MouseType                     `json:"type"`                  // Type of the mouse event.
	X           float64                       `json:"x"`                     // X coordinate of the event relative to the main frame's viewport in CSS pixels.
	Y           float64                       `json:"y"`                     // Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
	Modifiers   Modifier                      `json:"modifiers"`             // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
	Timestamp   *TimeSinceEpoch               `json:"timestamp,omitempty"`   // Time at which the event occurred.
	Button      ButtonType                    `json:"button,omitempty"`      // Mouse button (default: "none").
	Buttons     int64                         `json:"buttons,omitempty"`     // A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
	ClickCount  int64                         `json:"clickCount,omitempty"`  // Number of times the mouse button was clicked (default: 0).
	DeltaX      float64                       `json:"deltaX,omitempty"`      // X delta in CSS pixels for mouse wheel event (default: 0).
	DeltaY      float64                       `json:"deltaY,omitempty"`      // Y delta in CSS pixels for mouse wheel event (default: 0).
	PointerType DispatchMouseEventPointerType `json:"pointerType,omitempty"` // Pointer type (default: "mouse").
}

During the encoding they are ignored, not sure if this is the part causing the error?

	if in.DeltaX != 0 {
		const prefix string = ",\"deltaX\":"
		out.RawString(prefix)
		out.Float64(float64(in.DeltaX))
	}
	if in.DeltaY != 0 {
		const prefix string = ",\"deltaY\":"
		out.RawString(prefix)
		out.Float64(float64(in.DeltaY))
	}