// Click is an event fired when a pointing device button has been pressed and
// released on an element.
//
// https://developer.mozilla.org/docs/Web/Events/click
540716
func Click(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "click", Listener: listener}
}
57200
func Close(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "close", Listener: listener}
}
668141
func MovesClick(x, y int, args ...interface{}) {
	MoveSmooth(x, y)
	MouseClick(args...)
}
1132078
func DeviceMotion(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "devicemotion", Listener: listener}
}
1302454
func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action {
	return ActionFunc(func(ctx context.Context) error {
		var pos []int
		err := EvaluateAsDevTools(fmt.Sprintf(scrollIntoViewJS, n.FullXPath()), &pos).Do(ctx)
		if err != nil {
			return err
		}

		box, err := dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctx)
		if err != nil {
			return err
		}

		c := len(box.Content)
		if c%2 != 0 || c < 1 {
			return ErrInvalidDimensions
		}

		var x, y int64
		for i := 0; i < c; i += 2 {
			x += int64(box.Content[i])
			y += int64(box.Content[i+1])
		}
		x /= int64(c / 2)
		y /= int64(c / 2)

		return MouseClickXY(x, y, opts...).Do(ctx)
	})
}
1368522
func DoubleClick(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "dblclick", Listener: listener}
}
1089617
func (c *Client) Event(e *Event) error {
	if c == nil {
		return fmt.Errorf("Client is nil")
	}
	stat, err := e.Encode(c.Tags...)
	if err != nil {
		return err
	}
	return c.sendMsg([]byte(stat))
}
424243
func (m *Meta) touch(ptr interface{}) {
	if m.touched == nil {
		m.touched = make(map[interface{}]struct{}, 1)
	}
	m.touched[ptr] = struct{}{}
}
823417
func EndEvent(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "endEvent", Listener: listener}
}
434993
func (ctrl *GameController) Button(btn GameControllerButton) byte {
	return byte(C.SDL_GameControllerGetButton(ctrl.cptr(), btn.c()))
}
524485
func MouseDown(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "mousedown", Listener: listener}
}
11804
func Drag(x, y int, args ...string) {
	var button C.MMMouseButton = C.LEFT_BUTTON

	cx := C.size_t(x)
	cy := C.size_t(y)

	if len(args) > 0 {
		button = CheckMouse(args[0])
	}

	C.drag_mouse(cx, cy, button)
}
790627
func (f *Form) Click(button string) error {
	if _, ok := f.buttons[button]; !ok {
		return errors.NewInvalidFormValue(
			"Form does not contain a button with the name '%s'.", button)
	}
	return f.send(button, f.buttons[button][0])
}
277317
func (e *Element) Click() error {
	x, y, err := e.getCenter()
	if err != nil {
		return err
	}

	// click the centroid of the element.
	return e.tab.Click(float64(x), float64(y))
}
1328596
func (b *Button) OnKeyEvent(ev KeyEvent) {
	if !b.IsFocused() {
		return
	}
	if ev.Key == KeyEnter && b.onActivated != nil {
		b.onActivated(b)
	}
}
35809
func Blur(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "blur", Listener: listener}
}
989226
func Focus(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "focus", Listener: listener}
}