From bca31f0d7af8ce30fabf00c37ccaf89710698547 Mon Sep 17 00:00:00 2001 From: theGeekPirate Date: Fri, 27 Oct 2017 14:13:22 -0700 Subject: [PATCH] Added applyCursorVisibility() --- pixelgl/window.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pixelgl/window.go b/pixelgl/window.go index 30cee7e..4f4211c 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -324,15 +324,19 @@ func (w *Window) SetCursorVisible(visible bool) { if !w.cursorDisabled { w.cursorVisible = visible mainthread.Call(func() { - if visible { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) - } else { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden) - } + w.applyCursorVisibility() }) } } +func (w *Window) applyCursorVisibility() { + if w.cursorVisible { + w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) + } else { + w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden) + } +} + // CursorVisible returns the visibility status of the mouse cursor. func (w *Window) CursorVisible() bool { return w.cursorVisible @@ -346,11 +350,7 @@ func (w *Window) SetCursorDisabled(disabled bool) { w.cursorVisible = false w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled) } else { - if w.cursorVisible { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal) - } else { - w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden) - } + w.applyCursorVisibility() } }) }