示例#1
0
文件: events.go 项目: Zwobot/go.wde
func mouseButtonCallback(w *glfw.Window, button glfw.MouseButton,
	action glfw.Action, mod glfw.ModifierKey) {

	switch action {

	case glfw.Release:
		var bue wde.MouseUpEvent
		bue.Which = getMouseButton(button)
		x, y := w.GetCursorPosition()
		bue.Where.X = int(math.Floor(x))
		bue.Where.Y = int(math.Floor(y))
		if ws, ok := windowMap[w.C()]; ok {
			ws.events <- bue
		}

	case glfw.Press:
		var bde wde.MouseDownEvent
		bde.Which = getMouseButton(button)
		x, y := w.GetCursorPosition()
		bde.Where.X = int(math.Floor(x))
		bde.Where.Y = int(math.Floor(y))
		if ws, ok := windowMap[w.C()]; ok {
			ws.events <- bde
		}
	}
}
示例#2
0
文件: events.go 项目: Zwobot/go.wde
func cursorEnterCallback(w *glfw.Window, entered bool) {
	var event interface{}

	if entered {
		var ene wde.MouseEnteredEvent
		x, y := w.GetCursorPosition()
		ene.Where.X = int(math.Floor(x))
		ene.Where.Y = int(math.Floor(y))
		event = ene
	} else {
		var exe wde.MouseExitedEvent
		x, y := w.GetCursorPosition()
		exe.Where.X = int(math.Floor(x))
		exe.Where.Y = int(math.Floor(y))
		event = exe
	}

	if ws, ok := windowMap[w.C()]; ok {
		ws.events <- event
	}
}