From 884497f04937fdc672e80c0c24842fa23647e92b Mon Sep 17 00:00:00 2001 From: Liam Galvin Date: Tue, 27 Nov 2018 13:20:14 +0000 Subject: [PATCH] fix offset bug --- gui/mouse.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/mouse.go b/gui/mouse.go index 99aba12..a795c40 100644 --- a/gui/mouse.go +++ b/gui/mouse.go @@ -17,9 +17,12 @@ func (gui *GUI) glfwScrollCallback(w *glfw.Window, xoff float64, yoff float64) { } } -func (gui *GUI) mouseMoveCallback(w *glfw.Window, xpos float64, ypos float64) { +func (gui *GUI) mouseMoveCallback(w *glfw.Window, px float64, py float64) { + + scale := gui.scale() + px = px / float64(scale) + py = py / float64(scale) - px, py := w.GetCursorPos() x := uint16(math.Floor((px - float64(gui.renderer.areaX)) / float64(gui.renderer.CellWidth()))) y := uint16(math.Floor((py - float64(gui.renderer.areaY)) / float64(gui.renderer.CellHeight())))